Skip to content

A JavaScript test runner in the browser, no packages or installation.

Notifications You must be signed in to change notification settings

raul-fornell/web-test-runner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Test Runner

Jest like test runner for JavaScript code that runs in the browser. No installation needed.

Usage

Create a test file, import the TT test runner from test-runner.js.

Add tests with

TT.it('Test description', () => { ... });

Add specs with

TT.spec('Spec tests', (tt) => { ... }

Add tests to the specs function with

TT.spec('Spec tests', (tt) => {
  tt.it('Test description', () => { ... });
});

Check test results with

TT.expect(result).toBe("exact value");
TT.expect(result).greaterThan(0);
TT.expect(result).lowerThan(9999);
TT.expect(result).isString();

More comparisons can be added to the test-runner expect function if needed.

Skip specs and tests with

TT.skip.it( ...
TT.skip.spec( ...

Execute only these tests with

TT.only.it( ...
TT.only.spec( ...

Run the tests in the main html file, loading the helper file with

<script type="module" src="../test-runner-init.js"></script>

And finally open the console to see the tests running there.

Example Calculator web app

An example web with two tests suites can be found in the calculator folder.

Run with:

npx http-server

Or any http-server.

About

A JavaScript test runner in the browser, no packages or installation.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published