javascript - Does any testing frameworks support inline tests in TypeScript? -


i find karma js tests cumbersome set , write , find myself ignoring writing tests because of this, wanted know if there exist better alternatives.

since use typescript dream scenario if write this:

module adder {     export function add(a, b){         return + b;     } } [tests] assert.equal(4, adder.add(2, 2)); 

my tests inline , run directly in editor when changes in current file occur. since typescript remove tests final output put tests in same file code (the closer better in opinion). testing framework support , if not needed support scenario.

just pedantic note - karma test runner, not test framework. however, can use jasmine, mocha, qunit or roll-your-own test framework.

you might able use decorator syntax accomplish type of behaviour. like:

@testsuite class addertests {     @test     test1() {         assert.equal(4, adder.add(2,2));     }     @test     test2() {         assert.equal(0, adder.add(2,-2));     }  } 

having said this, though, structure of test code similar jasmine syntax:

describe('addertests', () => {     it('should add 2 , 2', () => {         expect(adder.add(2,2)).tobe(4);     }  }); 

your ideal, i.e:

[test] assert.equal( ... ) 

is not possible using typescript decorators, or generics. trying apply attribute arbitrary line of code. have function start, in order correctly use javascript scoping rules:

[test] test1() { assert.equal( ... ) }; 

Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -