Skip to content

Commit 13ece77

Browse files
Zirrodomenic
authored andcommitted
Switch from npm to Yarn
The proximate cause is npm/npm#17722, although perhaps we'll find more benefits.
1 parent 15abcc3 commit 13ece77

File tree

6 files changed

+3975
-5564
lines changed

6 files changed

+3975
-5564
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
gmon.out
55
v8.log
66
node_modules
7+
package-lock.json
78
test/worker-bundle.js
89
test/web-platform-tests/tuwpt-manifest.json
910
npm-debug.log*

.travis.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ git:
88
submodules: false
99

1010
script:
11-
- npm run lint
12-
- npm test
11+
- yarn lint
12+
- yarn test
1313

1414
branches:
1515
only:
@@ -28,7 +28,7 @@ matrix:
2828
include:
2929
- node_js: 6
3030
env: TEST_SUITE=node-canvas-prebuilt
31-
script: "export CXX=g++-4.8 && npm i canvas-prebuilt && npm test"
31+
script: "export CXX=g++-4.8 && yarn add canvas-prebuilt && yarn test"
3232
addons:
3333
hosts:
3434
- web-platform.test
@@ -39,7 +39,7 @@ matrix:
3939
- xn--lve-6lad.web-platform.test
4040
- node_js: 6
4141
env: TEST_SUITE=node-canvas
42-
script: "export CXX=g++-4.8 && npm i canvas && npm test"
42+
script: "export CXX=g++-4.8 && yarn add canvas && yarn test"
4343
addons:
4444
hosts:
4545
- web-platform.test
@@ -60,7 +60,7 @@ matrix:
6060
- build-essential
6161
- node_js: stable
6262
env: TEST_SUITE=node-canvas
63-
script: "export CXX=g++-4.8 && npm i canvas && npm test"
63+
script: "export CXX=g++-4.8 && yarn add canvas && yarn test"
6464
addons:
6565
hosts:
6666
- web-platform.test
@@ -79,7 +79,7 @@ matrix:
7979
- libpango1.0-dev
8080
- libgif-dev
8181
- build-essential
82-
- script: '[ "${TRAVIS_PULL_REQUEST}" != "false" ] || (npm run pretest && npm run test-browser)'
82+
- script: '[ "${TRAVIS_PULL_REQUEST}" != "false" ] || (yarn run pretest && yarn run test-browser)'
8383
env: TEST_SUITE=browser
8484
addons:
8585
sauce_connect:

Contributing.md

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
jsdom is, as said in our tagline, “A JavaScript implementation of the DOM and HTML standards.” Anything that helps us be better at that is welcome.
44

5+
## Yarn
6+
7+
We use the [Yarn](https://yarnpkg.com/) package manager to manage dependencies and run the scripts defined in `package.json`. It is similar to npm, but contains fewer bugs for our purposes. If you make changes which add or remove dependencies, make sure you commit the `yarn.lock` file which it generates.
8+
9+
You can probably get away with using npm for most contributions, as long as you are not adding or removing dependencies. You'll have to mentally translate the Yarn commands we give into npm ones, however.
10+
511
## Architecture
612

713
jsdom is a blend of old and new code. Some of its older and less-touched corners may look different from newer work. Here we'll describe the modern setup, but you might encounter parts of the codebase that don't fit this model, or that seem unnecessarily baroque (like the directory structure in `lib/`).
@@ -13,7 +19,7 @@ As such, most web platform classes present in jsdom are implemented in two parts
1319
- An IDL file, such as [`Attr.idl`](https://github.com/tmpvar/jsdom/blob/master/lib/jsdom/living/attributes/Attr.idl), drawn more or less straight from the spec
1420
- An implementation file, such as [`Attr-impl.js`](https://github.com/tmpvar/jsdom/blob/master/lib/jsdom/living/attributes/Attr-impl.js), containing the relevant implementation logic
1521

16-
Our build step (`npm run prepublish`) then generates a public API file (e.g. `Attr.js`) which takes care of all the Web IDL-derived boilerplate, delegating to the implementation file for the important stuff. We then wire it together with a line in `lib/jsdom/living/index.js` that exposes the generated class on all jsdom windows.
22+
Our build step (`yarn prepare`) then generates a public API file (e.g. `Attr.js`) which takes care of all the Web IDL-derived boilerplate, delegating to the implementation file for the important stuff. We then wire it together with a line in `lib/jsdom/living/index.js` that exposes the generated class on all jsdom windows.
1723

1824
## Contribution overview
1925

@@ -33,61 +39,61 @@ Other specs might pop up from time to time, especially in regard to CSS stuff. I
3339

3440
### Running the tests
3541

36-
First you'll want to `npm install`. Then, configure your system to run the web platform tests as described in [their README](https://github.com/w3c/web-platform-tests/blob/master/README.md). If you can't get that set up correctly, the test runner will make a best-faith effort to run the tests hosted on http://w3c-test.org/, but this is pretty slow and fragile.
42+
First you'll want to run `yarn` to install all dependencies. Then, configure your system to run the web platform tests as described in [their README](https://github.com/w3c/web-platform-tests/blob/master/README.md). If you can't get that set up correctly, the test runner will make a best-faith effort to run the tests hosted on http://w3c-test.org/, but this is pretty slow and fragile.
3743

38-
**To run all the tests:** `npm test`
44+
**To run all the tests:** `yarn test`
3945

4046
### Web platform feature tests
4147

4248
All tests for web platform features (as opposed to features of jsdom itself, such as the `JSDOM()` constructor) should be in [web-platform-tests](https://github.com/w3c/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](https://github.com/tmpvar/jsdom/blob/master/test/web-platform-tests/to-run.yaml). These tests are HTML files which use a special library called [testharness.js](http://testthewebforward.org/docs/testharness-library.html) to report their results.
4349

4450
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](https://github.com/tmpvar/jsdom/tree/master/test/web-platform-tests/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](https://github.com/w3c/web-platform-tests) repository.
4551

46-
**To run all web-platform-tests:** `npm run test-wpt`
52+
**To run all web-platform-tests:** `yarn test-wpt`
4753

48-
**To run the to-upstream web-platform-tests:** `npm run test-tuwpt`
54+
**To run the to-upstream web-platform-tests:** `yarn test-tuwpt`
4955

50-
**To run specific web-platform-tests already enabled via `to-run.yaml`**: `npm run test-wpt -- --fgrep dom/events`
56+
**To run specific web-platform-tests already enabled via `to-run.yaml`**: `yarn test-wpt -- --fgrep dom/events`
5157

52-
**To run specific to-upstream web-platform-tests**: `npm run test-tuwpt -- --fgrep domparsing`
58+
**To run specific to-upstream web-platform-tests**: `yarn test-tuwpt -- --fgrep domparsing`
5359

54-
Also, to update web platform tests to their latest revision from the source repository: `npm run update-wpt`. (This can take a long time.)
60+
Also, to update web platform tests to their latest revision from the source repository: `yarn update-wpt`. (This can take a long time, like 10 minutes.)
5561

5662
### jsdom API tests
5763

5864
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](https://mochajs.org/) and [Chai](http://chaijs.com/).
5965

6066
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`.
6167

62-
**To run all API tests:** `npm run test-api`
68+
**To run all API tests:** `yarn test-api`
6369

64-
**To run a specific API test:** `npm run test-mocha -- test/api/from-file.js`
70+
**To run a specific API test:** `yarn test-mocha -- test/api/from-file.js`
6571

6672
### Older tests
6773

68-
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 `npm test`, you will get the full test suite, including such old tests.
74+
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 `yarn test`, you will get the full test suite, including such old tests.
6975

7076
### Testing against the browser
7177

7278
jsdom has experimental support to run in directly in a browser, in both the main document and in a web worker! So we try run as many tests as possible in browsers too. Currently we only test in Chrome, since it has the same JavaScript features as the Node.js environment we usually develop in. So you'll need Chrome installed on your machine.
7379

7480
The mocha test cases are executed in Chrome using [karma](https://karma-runner.github.io/). Currently, web platform tests are not executed in the browser yet.
7581

76-
**To run all browser tests:** `npm run test-browser`
82+
**To run all browser tests:** `yarn test-browser`
7783

78-
**To run the karma tests in an iframe:** `npm run test-browser-iframe`
84+
**To run the karma tests in an iframe:** `yarn test-browser-iframe`
7985

80-
**To run the karma tests in a web worker:** `npm run test-browser-worker`
86+
**To run the karma tests in a web worker:** `yarn test-browser-worker`
8187

8288
## Benchmarks
8389

8490
This project cares about performance. There are a number of benchmarks that you can run. If you suspect your contribution has an impact on the performance of existing functionality, make sure you run the benchmarks before and after your change so that you can compare.
8591

8692
You can also run the benchmarks using the native DOM implementation of Chrome. A comparison with jsdom will automatically be made for you. If your new feature is much slower than the alternative DOM implementation, there might be an unexpected bottleneck somewhere in your change.
8793

88-
**To run benchmarks in Node.js:** `npm run benchmark`
94+
**To run benchmarks in Node.js:** `yarn benchmark`
8995

90-
**To run benchmarks in the browser:** `npm run benchmark-browser`, then open `benchmark/browser-runner.html` in Chrome (or Chromium) and use the developer console to execute the `run()` function.
96+
**To run benchmarks in the browser:** `yarn benchmark-browser`, then open `benchmark/browser-runner.html` in Chrome (or Chromium) and use the developer console to execute the `run()` function.
9197

9298
## Issues
9399

0 commit comments

Comments
 (0)