2

I'm looking to port a significant number of tests written in JUnit to test TypeScript code on Node.js. I know that annotations are an experimental feature in TypeScript/JavaScript, but ideally, it would use the same @Before, @Test, and @After source annotations that JUnit does.

Output in the same JUnit XML format would be plus as well.

2 Answers 2

2

I know that I might be kind of late with my answer, but you might want to checkout TestyTs

It supports annotations similar to JUnit:

@TestSuite()
export class MyTestSuite {

    @BeforeEach()
    beforeEach() {
        // Do something
    }

    @Test()
    onePlusOne() {
        const result = 1 + 1;
        expect.toBeEqual(result, 2);
    }

    @AfterEach()
    afterEach() {
        // Do something
    }
}

Try it on REPL

Sign up to request clarification or add additional context in comments.

Comments

1

but ideally, it would use the same @Before, @Test, and @After source annotations that JUnit does.

None of the popular js frameworks out there do that right now. Fwiw Mocha is the king of the test frameworks at the moment e.g. npm downloads http://www.npmtrends.com/mocha-vs-jasmine-vs-qunit-vs-jest-vs-ava

More

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.