title: How to unit test a cross-contract call using NEAR (AssemblyScript)?
body: <p>I'm trying to follow this example on how to create a <a href="https://docs.near.org/docs/tutorials/contracts/cross-contract-calls#step-6---more-tests" rel="nofollow noreferrer">unit test for a cross-contract</a> call.</p>
  <p>I have a cross-contract call like this</p>
  <pre class="lang-ts prettyprint-override"><code>// Class with cross-contract calls
  export class CalculatorApi {
    add(a: string, b: string): ContractPromise {
      let args: AddArgs = { a, b };
      let promise = ContractPromise.create(OTHER_CONTRACT, &quot;addLongNumbers&quot;, args.encode(), 100000000000000);
      return promise;
    }
  }
  
  
  // function to unit test
  export function calculate(a: string , b: string): void { // Need to return void according to current spec
    let calculator = new CalculatorApi();
    let promise = calculator.add(a, b);
    promise.returnAsResult();
  }
  </code></pre>
  <blockquote>
  <p>You may notice this function returns void, which is a bit confusing because the contract is returning a promise. This is because it's calling a function elsewhere and the compiler thinks it's void.</p>
  <p>(In future releases this will be changed.)</p>
  </blockquote>
  <p>And a test like this</p>
  <pre class="lang-ts prettyprint-override"><code>// VS Code complains about the async word
  it(&quot;add one digit&quot;, async function() {
    const params = { a: &quot;1&quot;, b: &quot;99&quot; };
    const result = await contract.calculate(params);
    expect(result).toBe(&quot;100&quot;);
  });
  </code></pre>
  <p>However, the above test complains about the syntax with the following error:</p>
  <blockquote>
  <p>An async function or method must return a 'Promise'. Make sure you
  have a declaration for 'Promise' or include 'ES2015' in your '--lib'
  option.ts(2697)</p>
  </blockquote>
  <p>I'm not sure, but maybe it has something to do with my <code>tsconfig.json</code> file, which looks like this:</p>
  <pre><code>{
    &quot;extends&quot;: &quot;../node_modules/assemblyscript/std/assembly.json&quot;,
    &quot;include&quot;: [&quot;./**/*.ts&quot;]
  }
  </code></pre>
  <p>I tried to add the following, but it didn't work</p>
  <pre><code>  &quot;compilerOptions&quot;: {
      &quot;lib&quot;: [&quot;es2020&quot;]
    }
  </code></pre>