Skip to content

Latest commit

 

History

History
70 lines (43 loc) · 2.3 KB

readme.md

File metadata and controls

70 lines (43 loc) · 2.3 KB

Testing

All test files are inside the test/ directory and ends with .test.html.

If one or more test is failing, the main GitHub workflow will fail during check tests step.

Code coverage from test files is monitored, this is documented in docs/code_coverage/code_coverage.md.

If you want to keep test files check How to use tests. Otherwise see How to remove tests.

How to use tests

Test files are written using jsenv philosophy:

A test file is a regular html file.

stuff

See src/tests/greet.test.html

Debug a test

As previously mentioned, according to jsenv philosophy a test file executes like a standard file. A test file can be debugged using the development server and Chrome devtools.

Screencast test with chrome devtools

Executing all tests

Use npm test command. It is configured to execute scripts/test.mjs which is responsible to find and execute all your test files.

Test files are executed twice, a first time on Chrome, a second time on Firefox.

> node ./scripts/test.mjs

✔ execution 1 of 2 completed (all completed)
file: tests/greet.test.html
runtime: chromium/97.0.4666.0
duration: 1.6 seconds

✔ execution 2 of 2 completed (all completed)
file: tests/greet.test.html
runtime: firefox/93.0
duration: 1.6 seconds

-------------- summary -----------------
2 executions: all completed
total duration: 3.7 seconds
----------------------------------------

Test coverage

See Code coverage.

How to remove tests

If you don't need test or want to use an other test framework/library follow the steps below.

  1. Remove Run tests step in .github/workflows/main.yml

  2. Remove these "scripts" in package.json

    • "test"
    • "test:coverage"
    • "playwright-install"
  3. Delete scripts/test.mjs

  4. Remove "@jsenv/assert" from "devDependencies" package.json