testem 3.21.0 → 3.21.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -36
- package/lib/server/index.js +11 -14
- package/lib/utils/promises.js +6 -1
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Got Scripts? Test’em!
|
|
2
2
|
=================
|
|
3
3
|
|
|
4
|
-
[](https://github.com/testem/testem/actions/workflows/ci.yml?query=branch%3Amain) [](https://badge.fury.io/js/testem)
|
|
5
5
|
|
|
6
6
|
Testem is a **JavaScript test runner** that runs your tests in **real desktop browsers**—Chrome, Firefox, Safari, Edge, and others you launch—so your specs execute in the same browser engines and DOM your users get, not a pretend environment. It also runs tests in **[Node](https://nodejs.org/)**, **Chrome** (including **headless** runs via `browser_args`, e.g. `--headless`), or any launcher you configure. It is **framework-agnostic** and aimed at **any kind of tests** you want to run: unit, integration, end-to-end style suites, or custom setups—you pick the style; Testem wires it to the browser or process.
|
|
7
7
|
|
|
@@ -60,11 +60,11 @@ The simplest way to use Testem, in the TDD spirit, is to start in an empty direc
|
|
|
60
60
|
|
|
61
61
|
You will see a terminal-based interface which looks like this
|
|
62
62
|
|
|
63
|
-

|
|
64
64
|
|
|
65
65
|
Now open a **real browser** (the URL Testem prints is a normal page in Chrome, Firefox, Safari, etc.) and go to the specified URL. You should now see
|
|
66
66
|
|
|
67
|
-

|
|
68
68
|
|
|
69
69
|
We see 0/0 for tests because at this point we haven't written any code. As we write them, Testem will pick up any `.js` files
|
|
70
70
|
that were added, include them, and if there are tests, run them automatically. So let's first write `hello_spec.js` in the spirit of "test first" (written in Jasmine)
|
|
@@ -78,7 +78,7 @@ describe('hello', function(){
|
|
|
78
78
|
```
|
|
79
79
|
Save that file and now you should see
|
|
80
80
|
|
|
81
|
-

|
|
82
82
|
|
|
83
83
|
Testem should automatically pick up the new files you've added and also any changes that you make to them and rerun the tests. The test fails as we'd expect. Now we implement the spec like so in `hello.js`
|
|
84
84
|
|
|
@@ -90,7 +90,7 @@ function hello(){
|
|
|
90
90
|
|
|
91
91
|
So you should now see
|
|
92
92
|
|
|
93
|
-

|
|
94
94
|
|
|
95
95
|
### Using the Text User Interface
|
|
96
96
|
|
|
@@ -143,7 +143,7 @@ To use Testem for continuous integration
|
|
|
143
143
|
|
|
144
144
|
testem ci
|
|
145
145
|
|
|
146
|
-
**GitHub Actions** is a common way to run Testem in CI: add a workflow job that runs `testem ci` (often with the **Headless Chrome** or **Chromium** launcher). This project’s own workflow is in [`.github/workflows/ci.yml`](https://github.com/testem/testem/blob/
|
|
146
|
+
**GitHub Actions** is a common way to run Testem in CI: add a workflow job that runs `testem ci` (often with the **Headless Chrome** or **Chromium** launcher). This project’s own workflow is in [`.github/workflows/ci.yml`](https://github.com/testem/testem/blob/main/.github/workflows/ci.yml).
|
|
147
147
|
|
|
148
148
|
In CI mode, Testem runs your tests on all the browsers that are available on the system one after another.
|
|
149
149
|
|
|
@@ -178,9 +178,9 @@ When you run `testem ci` to run tests, it outputs the results in the [TAP](https
|
|
|
178
178
|
|
|
179
179
|
# ok
|
|
180
180
|
|
|
181
|
-
TAP is a human-readable and language-agnostic test result format. On **GitHub Actions**, a typical pattern is a step that runs `testem ci` and relies on the exit code to fail the job (see [`.github/workflows/ci.yml`](https://github.com/testem/testem/blob/
|
|
181
|
+
TAP is a human-readable and language-agnostic test result format. On **GitHub Actions**, a typical pattern is a step that runs `testem ci` and relies on the exit code to fail the job (see [`.github/workflows/ci.yml`](https://github.com/testem/testem/blob/main/.github/workflows/ci.yml) in this repository). For **Jenkins** and **TeamCity**, use TAP plugins:
|
|
182
182
|
|
|
183
|
-
* [Jenkins TAP plugin](https://plugins.jenkins.io/tap/) - I've added [detailed instructions](https://github.com/testem/testem/blob/
|
|
183
|
+
* [Jenkins TAP plugin](https://plugins.jenkins.io/tap/) - I've added [detailed instructions](https://github.com/testem/testem/blob/main/docs/use_with_jenkins.md) for setup with Jenkins.
|
|
184
184
|
* [TeamCity TAP plugin](https://github.com/pavelsher/teamcity-tap-parser)
|
|
185
185
|
|
|
186
186
|
## TAP Options
|
|
@@ -511,6 +511,8 @@ When you run `testem`, it will auto-launch the mocha process based on the specif
|
|
|
511
511
|
Processes with TAP Output
|
|
512
512
|
-------------------------
|
|
513
513
|
|
|
514
|
+
Node's built-in test runner emits TAP with `node --test --test-reporter=tap` plus `"protocol": "tap"`. See the [node:test example](examples/node_test).
|
|
515
|
+
|
|
514
516
|
If your process outputs test results in [TAP](https://en.wikipedia.org/wiki/Test_Anything_Protocol) format, you can tell that to testem via the `protocol` property. For example
|
|
515
517
|
|
|
516
518
|
```javascript
|
|
@@ -522,8 +524,12 @@ If your process outputs test results in [TAP](https://en.wikipedia.org/wiki/Test
|
|
|
522
524
|
}
|
|
523
525
|
```
|
|
524
526
|
|
|
527
|
+
Vitest emits TAP with `--reporter=tap-flat` (use `vitest run`, not watch mode) plus `"protocol": "tap"`. See the [Vitest example](examples/vitest).
|
|
528
|
+
|
|
525
529
|
When this is done, Testem will read in the process's stdout and parse it as TAP, and then display the test results in Testem's normal format. It will also hide the process's stdout output from the console log panel, although it will still display the stderr.
|
|
526
530
|
|
|
531
|
+
Jest has no built-in TAP reporter, so the equivalent is a package such as [`jest-tap-reporter`](https://www.npmjs.com/package/jest-tap-reporter) plus `"protocol": "tap"`. See the [Jest example](examples/jest).
|
|
532
|
+
|
|
527
533
|
Headless Chrome
|
|
528
534
|
---------------
|
|
529
535
|
|
|
@@ -606,7 +612,7 @@ Let's say you want to serve `tests.html` at the top level url `/tests.html`, all
|
|
|
606
612
|
DIY: Use Any Test Framework
|
|
607
613
|
---------------------------
|
|
608
614
|
|
|
609
|
-
If you want to use Testem with a test framework that's not supported out of the box, you can write your own custom test framework adapter. See [customAdapter.js](https://github.com/testem/testem/blob/
|
|
615
|
+
If you want to use Testem with a test framework that's not supported out of the box, you can write your own custom test framework adapter. See [customAdapter.js](https://github.com/testem/testem/blob/main/examples/custom_adapter/customAdapter.js) for an example of how to write a custom adapter.
|
|
610
616
|
|
|
611
617
|
Then, to use it, in your config file simply set
|
|
612
618
|
|
|
@@ -614,7 +620,7 @@ Then, to use it, in your config file simply set
|
|
|
614
620
|
"framework": "custom"
|
|
615
621
|
```
|
|
616
622
|
|
|
617
|
-
And then make sure you include the adapter code in your test suite and you are ready to go. See here for the [full example](https://github.com/testem/testem/tree/
|
|
623
|
+
And then make sure you include the adapter code in your test suite and you are ready to go. See here for the [full example](https://github.com/testem/testem/tree/main/examples/custom_adapter).
|
|
618
624
|
|
|
619
625
|
Native notifications
|
|
620
626
|
--------------------------------
|
|
@@ -657,14 +663,18 @@ If you need to run a preprocessor (or indeed any shell command before the start
|
|
|
657
663
|
|
|
658
664
|
On Windows, list files explicitly in string hooks like this—cmd.exe does not expand `*` for external programs (see [Available hooks](docs/config_file.md#available-hooks) and the [coffeescript example](examples/coffeescript)). Testem's own `src_files` / `watch_files` globs are expanded by Testem, not by the hook shell.
|
|
659
665
|
|
|
660
|
-
or, with Babel (see the [Babel example](https://github.com/testem/testem/tree/
|
|
666
|
+
or, with Babel (see the [Babel example](https://github.com/testem/testem/tree/main/examples/babel)):
|
|
661
667
|
|
|
662
668
|
"before_tests": "babel src --out-dir ."
|
|
663
669
|
|
|
664
|
-
or, with a `tsconfig.json` that emits JavaScript next to your project (see the [TypeScript example](https://github.com/testem/testem/tree/
|
|
670
|
+
or, with a `tsconfig.json` that emits JavaScript next to your project (see the [TypeScript example](https://github.com/testem/testem/tree/main/examples/typescript)):
|
|
665
671
|
|
|
666
672
|
"before_tests": "tsc"
|
|
667
673
|
|
|
674
|
+
or, with Webpack + React (see the [Webpack + React example](https://github.com/testem/testem/tree/main/examples/webpack_react)):
|
|
675
|
+
|
|
676
|
+
"before_tests": "npx webpack"
|
|
677
|
+
|
|
668
678
|
And Testem will run it before each test run. Point **`src_files`** at the sources you want
|
|
669
679
|
watched (see **File watching** under Development Mode above).
|
|
670
680
|
|
|
@@ -695,29 +705,34 @@ If you would prefer simply to clean up when Testem exits, you can use the `on_ex
|
|
|
695
705
|
Example Projects
|
|
696
706
|
----------------
|
|
697
707
|
|
|
698
|
-
I've created [examples](https://github.com/testem/testem/tree/
|
|
699
|
-
|
|
700
|
-
* [Vite (middleware + plugin)](https://github.com/testem/testem/tree/
|
|
701
|
-
* [
|
|
702
|
-
* [
|
|
703
|
-
* [
|
|
704
|
-
* [
|
|
705
|
-
* [
|
|
706
|
-
* [Simple
|
|
707
|
-
* [Jasmine
|
|
708
|
-
* [
|
|
709
|
-
* [
|
|
710
|
-
* [Mocha
|
|
711
|
-
* [
|
|
712
|
-
* [
|
|
713
|
-
* [
|
|
714
|
-
* [
|
|
715
|
-
* [
|
|
716
|
-
* [
|
|
717
|
-
* [
|
|
718
|
-
* [
|
|
719
|
-
* [
|
|
720
|
-
* [
|
|
708
|
+
I've created [examples](https://github.com/testem/testem/tree/main/examples/) for various setups
|
|
709
|
+
|
|
710
|
+
* [Vite (middleware + plugin)](https://github.com/testem/testem/tree/main/examples/vite)
|
|
711
|
+
* [Vitest](https://github.com/testem/testem/tree/main/examples/vitest) - Vitest via a TAP process launcher (`tap-flat`).
|
|
712
|
+
* [Electron](https://github.com/testem/testem/tree/main/examples/electron)
|
|
713
|
+
* [TypeScript Project](https://github.com/testem/testem/tree/main/examples/typescript)
|
|
714
|
+
* [ESLint Example](https://github.com/testem/testem/tree/main/examples/eslint)
|
|
715
|
+
* [Babel Project](https://github.com/testem/testem/tree/main/examples/babel)
|
|
716
|
+
* [Simple QUnit project](https://github.com/testem/testem/tree/main/examples/qunit_simple)
|
|
717
|
+
* [Simple Jasmine project](https://github.com/testem/testem/tree/main/examples/jasmine_simple)
|
|
718
|
+
* [Jasmine 2](https://github.com/testem/testem/tree/main/examples/jasmine2)
|
|
719
|
+
* [Custom Jasmine project](https://github.com/testem/testem/tree/main/examples/jasmine_custom)
|
|
720
|
+
* [Simple Mocha Project](https://github.com/testem/testem/tree/main/examples/mocha_simple)
|
|
721
|
+
* [Simple React](https://github.com/testem/testem/tree/main/examples/react_simple) - React 19 in a real browser via import maps, no bundler.
|
|
722
|
+
* [Mocha + Chai](https://github.com/testem/testem/tree/main/examples/mocha_chai_simple)
|
|
723
|
+
* [Hybrid Project](https://github.com/testem/testem/tree/main/examples/hybrid_simple) - Mocha tests running in both the browser and Node.
|
|
724
|
+
* [Jest](https://github.com/testem/testem/tree/main/examples/jest) - Node Jest via a TAP process launcher (`jest-tap-reporter`).
|
|
725
|
+
* [Custom Test Framework](https://github.com/testem/testem/tree/main/examples/custom_adapter)
|
|
726
|
+
* [Tape Example](https://github.com/testem/testem/tree/main/examples/tape_example)
|
|
727
|
+
* [Node.js test runner](https://github.com/testem/testem/tree/main/examples/node_test) - `node:test` via a TAP process launcher.
|
|
728
|
+
* [Browserify Project](https://github.com/testem/testem/tree/main/examples/browserify)
|
|
729
|
+
* [Webpack + React](https://github.com/testem/testem/tree/main/examples/webpack_react) - React Testing Library in a real browser via Webpack and Mocha.
|
|
730
|
+
* [JSHint Example](https://github.com/testem/testem/tree/main/examples/jshint)
|
|
731
|
+
* [Coffeescript Project](https://github.com/testem/testem/tree/main/examples/coffeescript)
|
|
732
|
+
* [Custom Jasmine project using Require.js](https://github.com/testem/testem/tree/main/examples/jasmine_requirejs)
|
|
733
|
+
* [BrowserStack Integration](https://github.com/testem/testem/tree/main/examples/browserstack)
|
|
734
|
+
* [SauceLabs Integration](https://github.com/testem/testem/tree/main/examples/saucelabs)
|
|
735
|
+
* [Code Coverage with Istanbul](https://github.com/testem/testem/tree/main/examples/coverage_istanbul)
|
|
721
736
|
|
|
722
737
|
Historical Screencasts
|
|
723
738
|
----------------------
|
|
@@ -731,7 +746,7 @@ These YouTube screencasts are from around **2012** and may not match the current
|
|
|
731
746
|
Contributing
|
|
732
747
|
------------
|
|
733
748
|
|
|
734
|
-
If you want to [contribute to the project](https://github.com/testem/testem/blob/
|
|
749
|
+
If you want to [contribute to the project](https://github.com/testem/testem/blob/main/CONTRIBUTING.md), I am going to do my best to stay out of your way.
|
|
735
750
|
|
|
736
751
|
Core Maintainer(s)
|
|
737
752
|
------------------
|
package/lib/server/index.js
CHANGED
|
@@ -225,25 +225,22 @@ class Server extends EventEmitter {
|
|
|
225
225
|
}
|
|
226
226
|
|
|
227
227
|
shouldProxy(req, opts) {
|
|
228
|
-
var accepts;
|
|
229
|
-
var acceptCheck = [
|
|
230
|
-
'html',
|
|
231
|
-
'css',
|
|
232
|
-
'javascript'
|
|
233
|
-
];
|
|
234
|
-
|
|
235
228
|
//Only apply filtering logic if 'onlyContentTypes' key is present
|
|
236
229
|
if (!('onlyContentTypes' in opts)) {
|
|
237
230
|
return true;
|
|
238
231
|
}
|
|
239
232
|
|
|
240
|
-
|
|
241
|
-
acceptCheck
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
233
|
+
var onlyContentTypes = [].concat(opts.onlyContentTypes);
|
|
234
|
+
var acceptCheck = [
|
|
235
|
+
'html',
|
|
236
|
+
'css',
|
|
237
|
+
'javascript'
|
|
238
|
+
].concat(onlyContentTypes, 'text');
|
|
239
|
+
|
|
240
|
+
// req.accepts returns the single best matching type as a string, or false
|
|
241
|
+
// when the request accepts none of them.
|
|
242
|
+
var accepts = req.accepts(acceptCheck);
|
|
243
|
+
return accepts !== false && onlyContentTypes.indexOf(accepts) !== -1;
|
|
247
244
|
}
|
|
248
245
|
|
|
249
246
|
sendProxyError(res, err) {
|
package/lib/utils/promises.js
CHANGED
|
@@ -123,13 +123,18 @@ function mapLimit(arr, concurrency, fn) {
|
|
|
123
123
|
return Promise.all(workers).then(() => results);
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
async function retry(fn, { max_tries = 3 } = {}) {
|
|
126
|
+
async function retry(fn, { max_tries = 3, interval = 0, backoff = 1 } = {}) {
|
|
127
127
|
let lastErr;
|
|
128
|
+
let wait = interval;
|
|
128
129
|
for (let i = 0; i < max_tries; i++) {
|
|
129
130
|
try {
|
|
130
131
|
return await fn();
|
|
131
132
|
} catch (e) {
|
|
132
133
|
lastErr = e;
|
|
134
|
+
if (i < max_tries - 1 && wait > 0) {
|
|
135
|
+
await delay(wait);
|
|
136
|
+
wait *= backoff;
|
|
137
|
+
}
|
|
133
138
|
}
|
|
134
139
|
}
|
|
135
140
|
throw lastErr;
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"unittest",
|
|
8
8
|
"browser"
|
|
9
9
|
],
|
|
10
|
-
"version": "3.21.
|
|
10
|
+
"version": "3.21.2",
|
|
11
11
|
"author": "Toby Ho <airportyh@gmail.com>",
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
@@ -58,6 +58,8 @@
|
|
|
58
58
|
"cover": "cover run ./node_modules/.bin/_mocha tests/*_tests.js tests/**/*_tests.js; cover report html; open cover_html/index.html",
|
|
59
59
|
"integration": "node ./bin/run-integration.js",
|
|
60
60
|
"ci:safari-smoke": "node ./scripts/safari-ci-smoke.js",
|
|
61
|
+
"ci:legacy-phantomjs": "node ./scripts/legacy-phantomjs-ci-smoke.js",
|
|
62
|
+
"ci:legacy-ie": "node ./scripts/legacy-ie-sauce-smoke.js",
|
|
61
63
|
"browser-tests": "cd examples/saucelabs/ && ../../testem.js ci -d",
|
|
62
64
|
"lint": "eslint ."
|
|
63
65
|
},
|