@wpe-tkpd/jsdom

23.0.2 • Public • Published

This is fork of jsdom. Originally forked because we need to not import/require canvas and we need to use custom decimal.js.

Tests

Running the tests

  1. Run nvm use to ensure you use the Node.js version expected by this package.
  2. Run pnpm i to install all dependencies.

To run all the tests: pnpm test

In the following sections, we'll give commands for running a subset of the tests. If you do that, instead of running the whole suite with pnpm test, then please run this command first:

Before running test subsets: pnpm pretest

Web platform feature tests

All tests for web platform features (as opposed to features of jsdom itself, such as the JSDOM() constructor) should be in web-platform-tests format. We have some infrastructure for running these directly against jsdom documents. So ideally, when contributing a bugfix or new feature, you can browse the web-platform-tests repository and find the test covering your work, and then just enable it in the to-run.yaml file. These tests are HTML files which use a special library called testharness.js to report their results.

However, the web-platform-tests project is not fully comprehensive. If you need to write your own test for a web platform feature, place it in our to-upstream directory. (It's so named because, over time, we hope to upstream these tests back to the web-platform-tests repository, so all browsers can benefit from them.) Note that you may need to create new directory structure, paralleling that of the main web-platform-tests repository.

To run all web-platform-tests: pnpm test-wpt

To run the to-upstream web-platform-tests: pnpm test-tuwpt

To run specific web-platform-tests already enabled via to-run.yaml: pnpm test-wpt --fgrep dom/events

To run specific to-upstream web-platform-tests: pnpmp test-tuwpt --fgrep domparsing

Also, to update web platform tests to their latest revision from the source repository: pnpm update-wpt. (This can take a long time, like 10 minutes.)

jsdom API tests

If you are testing something that can only be accomplished through the jsdom API, and not inside a normal web browser, you'll want to write a different kind of test. Such tests are written using Mocha and Chai.

To write such a test that, simply add a file in test/api/, following the surrounding conventions. Then, add it to the manifest at test/index.js.

To run all API tests: pnpm test-api

To run a specific API test: pnpm test-mocha test/api/from-file.js

Older tests

Although ideally you should not need to worry about this, there are some tests that are for legacy reasons not in the right format; they use Mocha, but really should be web platform tests. We're keeping them around for coverage until we can convert them. If you run pnpm test, you will get the full test suite, including such old tests.

Dependents (1)

Package Sidebar

Install

npm i @wpe-tkpd/jsdom

Weekly Downloads

739

Version

23.0.2

License

Proprietary

Unpacked Size

2.94 MB

Total Files

473

Last publish

Collaborators

  • victorirawan
  • andywihalim2
  • prakasa1904
  • skipper.team
  • 1nd
  • adjieguntoro