Asynchronous tests in NTVS

Jul 3, 2014 at 8:58 PM
I think it's brilliant how asynchronous tests just work in NTVS, for example, we have code like the following (using TypeScript)
MyClass {

  myMethod(){

    return (
        promise.then(result1 => {
          
            // some work with result1

           return (
              promise.then(result2 => {
                   // some work with result 2
                    return 'foo';    
            })
           );
         })
   );
  }
}
I can now write a test case like the following:
export function mytest () {
     
     // SUT
     var myClass = new MyClass();

      // Act
      myClass.myMethod().then( result => {

            // Assert
            assert.areEqual('foo', result, 'Result should always be foo');
      });
}
Unfortunately, something gets lost at some point and the assertion doesn't actually get executed. However, the following workaround does result in the assertion:

    setTimeout( () => {
          // Assert
            assert.areEqual('foo', result, 'Result should always be foo');
     ));
Basically, the framework is not able to identify the setTimeout inside the Promise, but if one is set explicitly then everything works.

The point I wish to raise is the following:

Can someone please confirm that this is the right way to formulate asynchronous tests in NTVS? We are increasing writing more test cases and we don't want the whole thing to come crashing down by relying on some unsupported feature of NTVS.

I am delighted that asynchronous testing is so simple.

Thanks.