title: get value from a Promise for unit-testing
body: <p>I have a method inside a class calculating the sum of 2 parameters that returns a Promise (a must):</p>
  <pre><code>module.exports = class Sum {
    sum(a, b) {
      let c = a + b;
      const myPromise = new Promise(function(myResolve) {
        setTimeout(function(){ myResolve(c); }, 100);
      });
      return myPromise;
    }
  }
  </code></pre>
  <p>I use Jasmine framework to unit-test</p>
  <pre><code>const MyLocalVariable1 = require('../src/sum'); 
  describe('CommonJS modules', () =&gt; {
    it('should import whole module using module.exports = sum;', async () =&gt; {
      const result = new MyLocalVariable1();
      expect(result.sum(4, 5).then(function(value) {
        return value;
      })).toBe(9);
    });
  }
  </code></pre>
  <p>The first expression is what we want to test:</p>
  <pre><code>result.sum(4, 5).then(function(value) {
    return value;
  })
  </code></pre>
  <p>and the second one is the expected value:</p>
  <pre><code>toBe(9)
  </code></pre>
  <p>But how can I get a value from the first expression, because it's a Promise, and expected value of it is <em>[object Promise]</em>. Thanks in advance</p>