2023-03-26 05:22:09 -04:00
|
|
|
# Tools for Node.js compatibility work
|
|
|
|
|
|
|
|
We run
|
|
|
|
[native Node.js test cases](https://github.com/nodejs/node/tree/main/test)
|
|
|
|
against our Node.js compatibility feature.
|
|
|
|
|
|
|
|
This directory includes the tools for downloading, setting up, and updating the
|
|
|
|
Node.js compat testing in Deno repository.
|
|
|
|
|
|
|
|
- `//tools/node_compat/setup.ts`
|
|
|
|
- This script sets up the Node.js compat tests.
|
2023-06-26 09:10:27 -04:00
|
|
|
- `//tools/node_compat/versions/`
|
2023-03-26 05:22:09 -04:00
|
|
|
- Node.js source tarballs and extracted test cases are stored here.
|
2024-03-05 15:49:21 -05:00
|
|
|
- `//tests/node_compat/config.jsonc`
|
2023-03-26 05:22:09 -04:00
|
|
|
- This json file stores the settings about which Node.js compat test to run
|
|
|
|
with Deno.
|
2024-03-05 15:49:21 -05:00
|
|
|
- `//tests/node_compat/test`
|
2023-03-26 05:22:09 -04:00
|
|
|
- The actual test cases are stored here.
|
|
|
|
|
|
|
|
## Steps to add new test cases from Node.js test cases
|
|
|
|
|
2024-03-05 15:49:21 -05:00
|
|
|
1. Update `tests` property of `//tests/node_compat/config.jsonc`. For example,
|
|
|
|
if you want to add `test/parallel/test-foo.js` from Node.js test cases, then
|
|
|
|
add `test-foo.js` entry in `tests.parallel` array property in `config.jsonc`
|
2023-06-01 04:31:06 -04:00
|
|
|
1. Run `deno task setup` in `tools/node_compat` dir.
|
2023-03-26 05:22:09 -04:00
|
|
|
|
|
|
|
The above command copies the updated items from Node.js tarball to the Deno
|
|
|
|
source tree.
|
|
|
|
|
|
|
|
Ideally Deno should pass the Node.js compat tests without modification, but if
|
2023-06-26 09:10:27 -04:00
|
|
|
you need to modify it, then add that item in `ignore` property of
|
2023-05-25 23:00:29 -04:00
|
|
|
`config.jsonc`. Then `setup.ts` doesn't overwrite the modified Node.js test
|
|
|
|
cases anymore.
|
2023-03-26 05:22:09 -04:00
|
|
|
|
|
|
|
If the test needs to be ignored in particular platform, then add them in
|
2023-05-25 23:00:29 -04:00
|
|
|
`${platform}Ignore` property of `config.jsonc`
|
2023-03-26 05:22:09 -04:00
|
|
|
|
|
|
|
## Run Node.js test cases
|
|
|
|
|
|
|
|
Node.js compat tests are run as part of `cargo test` command. If you want to run
|
|
|
|
only the Node.js compat test cases you can use the command
|
2023-06-01 04:31:06 -04:00
|
|
|
`cargo test node_compat`. If you want to run specific tests you can use the
|
2023-06-26 09:10:27 -04:00
|
|
|
command `deno task test` (in `tools/node_compat` dir). For example, if you want
|
2023-06-01 04:31:06 -04:00
|
|
|
to run all test files which contains `buffer` in filename you can use the
|
|
|
|
command:
|
|
|
|
|
|
|
|
```shellsession
|
|
|
|
/path/to/deno/tools/node_compat
|
|
|
|
$ deno task test buffer
|
|
|
|
```
|