title: How to override jasmine.Spec.prototype.addExpectationResult for Protractor in TypeScript?
body: <p>I have some (actually a lot) of Protractor tests in <strong>TypeScript</strong> and I need to take a screenshot in case of failures - from an <code>expect</code>or timeout - and I want to use the image on my <a href="http://allure.qatools.ru/" rel="nofollow noreferrer">Allure Report</a>.</p>
  
  <p>I originally tried the solution presented at <a href="https://www.protractortest.org/#/faq#how-can-i-get-screenshots-of-failures-" rel="nofollow noreferrer">Protractor's FAQ</a> creating a custom report or taking the screenshot inside the <code>jasmine. getEnv().afterAll</code> but that didn't work - the image is being attached to the wrong spec.</p>
  
  <p>So I tried to overriding <code>jasmine.Spec.prototype.addExpectationResult</code>, but I'm getting the error: <strong>"Property 'Spec' does not exist on type 'typeof jasmine'.ts(2339)"</strong>.</p>
  
  <p>I used a workaround to make that work (and it actually worked) as you can see bellow:</p>
  
  <pre class="lang-js prettyprint-override"><code>const jasmine2 = jasmine as any; // &lt;--- HERE !!!
  const addExpectationResult = jasmine2.Spec.prototype.addExpectationResult;
  
  jasmine2.Spec.prototype.addExpectationResult = function() {
    if (!arguments[0]) {
      // Takes screenshot
      allure.createAttachment('screenshot', Buffer.from(base64, 'base64'), 'image/png');
    }
  
    return addExpectationResult.apply(this, arguments);
  };
  </code></pre>
  
  <p>BUT is there any way of overrinding the <code>addExpectationResult</code> in a "better" way in <strong>TypeScript</strong>?</p>
  
  <p>I have in my <code>package.json</code> file the following <code>@types</code>:</p>
  
  <pre><code>"devDependencies": {
    "@types/jasmine": "^3.4.4",
    "@types/jasminewd2": "^2.0.8"
  }
  </code></pre>
  
  <p>Thanks in advance.</p>