testem 3.19.1 → 3.20.1
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 +175 -134
- package/lib/api.js +1 -1
- package/lib/app.js +186 -116
- package/lib/cli-local-delegation.js +93 -0
- package/lib/config.js +260 -119
- package/lib/file_watcher.js +111 -37
- package/lib/file_watcher_impl.js +295 -0
- package/lib/launcher.js +7 -12
- package/lib/reporters/dev/runner_tabs.js +52 -47
- package/lib/reporters/dev/split_log_panel.js +1 -1
- package/lib/reporters/dev/toast_notify.js +5 -0
- package/lib/runners/browser_test_runner.js +3 -1
- package/lib/runners/hook_runner.js +0 -1
- package/lib/server/index.js +39 -10
- package/lib/tap_consumer.js +73 -11
- package/lib/utils/esbuild-browser-polyfills.js +1 -1
- package/lib/utils/esbuild-buffer-inject.js +1 -1
- package/lib/utils/expand_glob_pattern.js +19 -0
- package/lib/utils/file_watch_glob_policy.js +119 -0
- package/lib/utils/is_emfile_error.js +16 -0
- package/lib/utils/known-browsers.js +155 -118
- package/lib/utils/path_pattern_match.js +39 -0
- package/lib/utils/process.js +42 -0
- package/lib/utils/promises.js +20 -1
- package/lib/utils/reporter.js +2 -2
- package/lib/utils/tmp-cleanup.js +26 -0
- package/package.json +40 -31
- package/testem.js +174 -78
package/README.md
CHANGED
|
@@ -1,49 +1,50 @@
|
|
|
1
1
|
Got Scripts? Test’em!
|
|
2
2
|
=================
|
|
3
3
|
|
|
4
|
-
[](https://github.com/testem/testem/actions/workflows/ci.yml?query=branch%3Amaster) [](
|
|
4
|
+
[](https://github.com/testem/testem/actions/workflows/ci.yml?query=branch%3Amaster) [](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
|
+
|
|
8
|
+
Unit testing in JavaScript can be tedious and painful, but Testem makes it so easy that you will actually *want* to write tests.
|
|
7
9
|
|
|
8
10
|
Features
|
|
9
11
|
--------
|
|
10
12
|
|
|
11
|
-
* Test-framework agnostic. Support for
|
|
12
|
-
- [Jasmine](
|
|
13
|
-
- [QUnit](
|
|
14
|
-
- [Mocha](
|
|
13
|
+
* Test-framework agnostic — designed for **any kind of tests** that fit your project (unit, integration, custom runners, etc.), not a single prescribed style. Support for
|
|
14
|
+
- [Jasmine](https://jasmine.github.io/)
|
|
15
|
+
- [QUnit](https://qunitjs.com/)
|
|
16
|
+
- [Mocha](https://mochajs.org/)
|
|
15
17
|
- Others, through custom test framework adapters.
|
|
16
|
-
* Run tests in all major browsers as well as [Node](
|
|
18
|
+
* Run tests in **all** major **real** browsers (your tests load and run in the actual browser) as well as [Node](https://nodejs.org) and **Chrome** (use `browser_args` with `--headless` for headless runs—see `docs/browser_args.md`)
|
|
17
19
|
* Two distinct use-cases:
|
|
18
20
|
- Test-Driven-Development(TDD) — designed to streamline the TDD workflow
|
|
19
|
-
- Continuous Integration(CI) — designed to work well with
|
|
21
|
+
- Continuous Integration(CI) — designed to work well with **GitHub Actions** and other CI systems, including Jenkins and TeamCity
|
|
20
22
|
* Cross-platform support
|
|
21
|
-
-
|
|
23
|
+
- macOS
|
|
22
24
|
- Windows
|
|
23
25
|
- Linux
|
|
24
26
|
* Preprocessor support
|
|
25
|
-
-
|
|
27
|
+
- Babel
|
|
28
|
+
- TypeScript
|
|
26
29
|
- Browserify
|
|
27
|
-
- JSHint/JSLint
|
|
30
|
+
- ESLint/JSHint/JSLint
|
|
31
|
+
- CoffeeScript
|
|
28
32
|
- everything else
|
|
29
33
|
|
|
30
|
-
Screencasts
|
|
31
|
-
-----------
|
|
32
|
-
|
|
33
|
-
* Watch this **[introductory screencast (11:39)](http://www.youtube.com/watch?v=-1mjv4yk5JM)** to see it in action! This one demonstrates the TDD workflow.
|
|
34
|
-
* [Launchers (12:10)](http://www.youtube.com/watch?v=Up0lVjWk9Rk) — more detail about launchers: how to specify what to auto-launch and how to configure one yourself to run tests in **Node**.
|
|
35
|
-
* [Continuous Integration (CI) Mode (4:24)](http://www.youtube.com/watch?v=Js16Cj80HKY) — details about how CI mode works.
|
|
36
|
-
* [Making JavaScript Testing Fun With Testem (22:53)](http://net.tutsplus.com/tutorials/javascript-ajax/make-javascript-testing-fun-with-testem/) — a thorough screencast by NetTuts+'s Jeffery Way covering the basics, Jasmine, Mocha/Chai, CoffeeScript and more!
|
|
37
|
-
|
|
38
34
|
Installation
|
|
39
35
|
------------
|
|
40
|
-
|
|
36
|
+
Testem needs a supported **[Node.js](https://nodejs.org/)** runtime. The required range is defined in [`package.json`](package.json) under `engines` (currently **^20.19.0**, **^22.12.0**, or **>=24.0.0**).
|
|
37
|
+
|
|
38
|
+
**Recommended:** install Testem **both** as a **dev dependency** (so your project pins a version) **and** **globally** (so the `testem` command is always available on your `PATH`):
|
|
41
39
|
|
|
42
|
-
|
|
40
|
+
```bash
|
|
41
|
+
npm install testem --save-dev
|
|
42
|
+
npm install testem -g
|
|
43
|
+
```
|
|
43
44
|
|
|
44
|
-
|
|
45
|
+
When you run the global `testem` inside a project directory that has a local `testem` install, the CLI **automatically re-runs the local copy** so the version stays in sync with `package.json`. Set **`TESTEM_USE_GLOBAL=1`** if you ever need to force the global binary only.
|
|
45
46
|
|
|
46
|
-
This
|
|
47
|
+
This README uses the `testem` command in examples; add it to npm scripts or invoke it as `testem` from a shell after the installs above.
|
|
47
48
|
|
|
48
49
|
Usage
|
|
49
50
|
-----
|
|
@@ -61,7 +62,7 @@ You will see a terminal-based interface which looks like this
|
|
|
61
62
|
|
|
62
63
|

|
|
63
64
|
|
|
64
|
-
Now open
|
|
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
|
|
65
66
|
|
|
66
67
|

|
|
67
68
|
|
|
@@ -107,6 +108,28 @@ In development mode, Testem has a text-based graphical user interface which uses
|
|
|
107
108
|
* d : half a page down target text panel
|
|
108
109
|
* u : half a page up target text panel
|
|
109
110
|
|
|
111
|
+
### File watching
|
|
112
|
+
|
|
113
|
+
In development mode, Testem watches your project directory for changes and re-runs tests when a
|
|
114
|
+
relevant file is added, edited, or removed. Watching is implemented with
|
|
115
|
+
[chokidar](https://github.com/paulmillr/chokidar) (v5).
|
|
116
|
+
|
|
117
|
+
* **`src_files`** — Glob patterns for source files whose changes should trigger a run (defaults to
|
|
118
|
+
`*.js` when unset). This is the main *watch list*.
|
|
119
|
+
* **`watch_files`** — Optional; if set, these patterns are watched instead of defaulting to
|
|
120
|
+
`src_files` (see `docs/config_file.md`).
|
|
121
|
+
* **`src_files_ignore`** — Patterns to exclude from the watch policy (e.g. `node_modules`).
|
|
122
|
+
* **`disable_watching`** — Set to `true` to turn off the file watcher entirely.
|
|
123
|
+
|
|
124
|
+
Testem watches the **current working directory** and applies your include/ignore patterns to
|
|
125
|
+
events from the watcher. You do not need to list every file explicitly; globs and ignores follow
|
|
126
|
+
the same policy as in the config reference.
|
|
127
|
+
|
|
128
|
+
**Troubleshooting:** On some setups (Docker, network filesystems, VMs), native `fs.watch` can be
|
|
129
|
+
flaky. Chokidar supports environment variables such as `CHOKIDAR_USE_POLLING=1` (force polling)
|
|
130
|
+
and `CHOKIDAR_INTERVAL` (polling interval in ms). See the
|
|
131
|
+
[chokidar readme](https://github.com/paulmillr/chokidar) for details.
|
|
132
|
+
|
|
110
133
|
### Command line options
|
|
111
134
|
|
|
112
135
|
To see all command line options
|
|
@@ -120,6 +143,8 @@ To use Testem for continuous integration
|
|
|
120
143
|
|
|
121
144
|
testem ci
|
|
122
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/master/.github/workflows/ci.yml).
|
|
147
|
+
|
|
123
148
|
In CI mode, Testem runs your tests on all the browsers that are available on the system one after another.
|
|
124
149
|
|
|
125
150
|
You can run multiple browsers in parallel in CI mode by specifying the `--parallel` (or `-P`) option to be the number of concurrent running browsers.
|
|
@@ -134,21 +159,18 @@ Will print them out. The output might look like
|
|
|
134
159
|
|
|
135
160
|
$ testem launchers
|
|
136
161
|
Browsers available on this system:
|
|
137
|
-
|
|
138
|
-
IE8
|
|
139
|
-
IE9
|
|
162
|
+
IE11
|
|
140
163
|
Chrome
|
|
141
164
|
Firefox
|
|
142
165
|
Safari
|
|
143
166
|
Safari Technology Preview
|
|
144
167
|
Opera
|
|
145
|
-
PhantomJS
|
|
146
168
|
|
|
147
|
-
|
|
169
|
+
Your machine may list other launchers too. For **headless** runs, prefer **Chrome** with `browser_args` (for example `--headless`) rather than the deprecated PhantomJS launcher—see `docs/browser_args.md`.
|
|
148
170
|
|
|
149
|
-
When you run `testem ci` to run tests, it outputs the results in the [TAP](
|
|
171
|
+
When you run `testem ci` to run tests, it outputs the results in the [TAP](https://testanything.org/) format by default, which looks like
|
|
150
172
|
|
|
151
|
-
ok 1 Chrome
|
|
173
|
+
ok 1 Chrome 130.0 - hello should say hello.
|
|
152
174
|
|
|
153
175
|
1..1
|
|
154
176
|
# tests 1
|
|
@@ -156,9 +178,9 @@ When you run `testem ci` to run tests, it outputs the results in the [TAP](http:
|
|
|
156
178
|
|
|
157
179
|
# ok
|
|
158
180
|
|
|
159
|
-
TAP is a human-readable and language-agnostic test result format.
|
|
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/master/.github/workflows/ci.yml) in this repository). For **Jenkins** and **TeamCity**, use TAP plugins:
|
|
160
182
|
|
|
161
|
-
* [Jenkins TAP plugin](https://
|
|
183
|
+
* [Jenkins TAP plugin](https://plugins.jenkins.io/tap/) - I've added [detailed instructions](https://github.com/testem/testem/blob/master/docs/use_with_jenkins.md) for setup with Jenkins.
|
|
162
184
|
* [TeamCity TAP plugin](https://github.com/pavelsher/teamcity-tap-parser)
|
|
163
185
|
|
|
164
186
|
## TAP Options
|
|
@@ -203,13 +225,14 @@ Testem has other test reporters besides TAP: `dot`, `xunit` and `teamcity`. You
|
|
|
203
225
|
|
|
204
226
|
You can also [add your own reporter](docs/custom_reporter.md).
|
|
205
227
|
|
|
206
|
-
|
|
228
|
+
<details>
|
|
229
|
+
<summary>Example <code>xunit</code> reporter output</summary>
|
|
207
230
|
|
|
208
231
|
Note that the real output is not pretty printed.
|
|
209
232
|
```xml
|
|
210
|
-
<testsuite name="Testem Tests" tests="4" failures="1" timestamp="
|
|
211
|
-
<testcase classname="
|
|
212
|
-
<testcase classname="
|
|
233
|
+
<testsuite name="Testem Tests" tests="4" failures="1" timestamp="2026-04-25T10:00:00.000Z" time="9">
|
|
234
|
+
<testcase classname="Firefox 128" name="myFunc returns true when input is valid" time="0"/>
|
|
235
|
+
<testcase classname="Firefox 128" name="myFunc returns false when user tickles it" time="0"/>
|
|
213
236
|
<testcase classname="Chrome" name="myFunc returns true when input is valid" time="0"/>
|
|
214
237
|
<testcase classname="Chrome" name="myFunc returns false when user tickles it" time="0">
|
|
215
238
|
<failure name="myFunc returns false when user tickles it" message="function is not ticklish">
|
|
@@ -221,17 +244,24 @@ Note that the real output is not pretty printed.
|
|
|
221
244
|
</testsuite>
|
|
222
245
|
```
|
|
223
246
|
|
|
224
|
-
|
|
247
|
+
</details>
|
|
225
248
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
##teamcity[testStarted name='PhantomJS 1.9 - hello should say hello to person']
|
|
229
|
-
##teamcity[testFinished name='PhantomJS 1.9 - hello should say hello to person']
|
|
230
|
-
##teamcity[testStarted name='PhantomJS 1.9 - goodbye should say goodbye']
|
|
231
|
-
##teamcity[testFailed name='PhantomJS 1.9 - goodbye should say goodbye' message='expected |'hello world|' to equal |'goodbye world|'' details='AssertionError: expected |'hello world|' to equal |'goodbye world|'|n at http://localhost:7357/testem/chai.js:873|n at assertEqual (http://localhost:7357/testem/chai.js:1386)|n at http://localhost:7357/testem/chai.js:3627|n at http://localhost:7357/hello_spec.js:14|n at callFn (http://localhost:7357/testem/mocha.js:4338)|n at http://localhost:7357/testem/mocha.js:4331|n at http://localhost:7357/testem/mocha.js:4728|n at http://localhost:7357/testem/mocha.js:4819|n at next (http://localhost:7357/testem/mocha.js:4653)|n at http://localhost:7357/testem/mocha.js:4663|n at next (http://localhost:7357/testem/mocha.js:4601)|n at http://localhost:7357/testem/mocha.js:4630|n at timeslice (http://localhost:7357/testem/mocha.js:5761)']
|
|
232
|
-
##teamcity[testFinished name='PhantomJS 1.9 - goodbye should say goodbye']
|
|
249
|
+
<details>
|
|
250
|
+
<summary>Example <code>teamcity</code> reporter output</summary>
|
|
233
251
|
|
|
234
|
-
|
|
252
|
+
```text
|
|
253
|
+
##teamcity[testStarted name='Firefox 128 - hello should say hello']
|
|
254
|
+
##teamcity[testFinished name='Firefox 128 - hello should say hello']
|
|
255
|
+
##teamcity[testStarted name='Firefox 128 - hello should say hello to person']
|
|
256
|
+
##teamcity[testFinished name='Firefox 128 - hello should say hello to person']
|
|
257
|
+
##teamcity[testStarted name='Firefox 128 - goodbye should say goodbye']
|
|
258
|
+
##teamcity[testFailed name='Firefox 128 - goodbye should say goodbye' message='expected |'hello world|' to equal |'goodbye world|'' details='AssertionError: expected |'hello world|' to equal |'goodbye world|'|n at http://localhost:7357/testem/chai.js:873|n at assertEqual (http://localhost:7357/testem/chai.js:1386)|n at http://localhost:7357/testem/chai.js:3627|n at http://localhost:7357/hello_spec.js:14|n at callFn (http://localhost:7357/testem/mocha.js:4338)|n at http://localhost:7357/testem/mocha.js:4331|n at http://localhost:7357/testem/mocha.js:4728|n at http://localhost:7357/testem/mocha.js:4819|n at next (http://localhost:7357/testem/mocha.js:4653)|n at http://localhost:7357/testem/mocha.js:4663|n at next (http://localhost:7357/testem/mocha.js:4601)|n at http://localhost:7357/testem/mocha.js:4630|n at timeslice (http://localhost:7357/testem/mocha.js:5761)']
|
|
259
|
+
##teamcity[testFinished name='Firefox 128 - goodbye should say goodbye']
|
|
260
|
+
|
|
261
|
+
##teamcity[testSuiteFinished name='mocha.suite' duration='11091']
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
</details>
|
|
235
265
|
|
|
236
266
|
### Command line options
|
|
237
267
|
|
|
@@ -242,9 +272,9 @@ To see all command line options for CI
|
|
|
242
272
|
Configuration File
|
|
243
273
|
------------------
|
|
244
274
|
|
|
245
|
-
For the simplest JavaScript projects, the TDD workflow described above will work fine. There are times when you want
|
|
246
|
-
|
|
247
|
-
This calls for the `testem.json` configuration file (you can also alternatively use the YAML format with a `testem.yml` file). It looks like
|
|
275
|
+
For the simplest JavaScript projects, the TDD workflow described above will work fine. There are times when you want to structure your source files into separate directories, or want to have finer control over what files to include.
|
|
276
|
+
|
|
277
|
+
This calls for the `testem.json` configuration file (you can also alternatively use the YAML format with a `testem.yml` file or return json from a javascript file `testem.js`). It looks like
|
|
248
278
|
|
|
249
279
|
```json
|
|
250
280
|
{
|
|
@@ -312,10 +342,10 @@ Or if you are using require.js or another loader, just make sure you load `/test
|
|
|
312
342
|
|
|
313
343
|
### Dynamic Substitution
|
|
314
344
|
|
|
315
|
-
To enable dynamic substitutions within the
|
|
345
|
+
To enable dynamic substitutions within the JavaScript files in your custom test page, you must
|
|
316
346
|
|
|
317
347
|
1. name your test page using `.mustache` as the extension
|
|
318
|
-
2. use `{{#serve_files}}` to loop over the set of
|
|
348
|
+
2. use `{{#serve_files}}` to loop over the set of JavaScript files to be served, and then reference its `src` property to access their path (or `{{#css_files}}` for stylesheets)
|
|
319
349
|
|
|
320
350
|
Example:
|
|
321
351
|
|
|
@@ -369,14 +399,14 @@ You can add your own custom paths to browser binaries by including `browser_path
|
|
|
369
399
|
|
|
370
400
|
```javascript
|
|
371
401
|
"browser_paths": {
|
|
372
|
-
"Chromium": "./
|
|
402
|
+
"Chromium": "./path/to/chromium"
|
|
373
403
|
}
|
|
374
404
|
"browser_exes": {
|
|
375
405
|
"Chromium": "chrome-custom-binary"
|
|
376
406
|
}
|
|
377
407
|
```
|
|
378
408
|
|
|
379
|
-
Adding a browser_path for a browser will override all default places for testem to look for the browser. So if the browser doesn't exist at the path you provided, you will get failures.
|
|
409
|
+
Set `Chromium` to a real browser binary path, for example the Chromium or Chrome under your Puppeteer install (the exact `path/to/chromium` depends on your platform and Puppeteer version). Adding a browser_path for a browser will override all default places for testem to look for the browser. So if the browser doesn't exist at the path you provided, you will get failures.
|
|
380
410
|
|
|
381
411
|
Customizing Browser Arguments
|
|
382
412
|
-----------------------------
|
|
@@ -413,7 +443,7 @@ When you run `testem`, it will auto-launch the mocha process based on the specif
|
|
|
413
443
|
Processes with TAP Output
|
|
414
444
|
-------------------------
|
|
415
445
|
|
|
416
|
-
If your process outputs test results in [TAP](
|
|
446
|
+
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
|
|
417
447
|
|
|
418
448
|
```javascript
|
|
419
449
|
"launchers": {
|
|
@@ -426,60 +456,38 @@ If your process outputs test results in [TAP](http://en.wikipedia.org/wiki/Test_
|
|
|
426
456
|
|
|
427
457
|
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.
|
|
428
458
|
|
|
429
|
-
|
|
430
|
-
|
|
459
|
+
Headless Chrome
|
|
460
|
+
---------------
|
|
431
461
|
|
|
432
|
-
|
|
462
|
+
Testem ships a **Headless Chrome** launcher that runs [Google Chrome](https://www.google.com/chrome/) (or Chromium where that is the detected binary) with **`--headless`**, **`--disable-gpu`**, and other defaults suitable for CI and unattended runs. You need Chrome installed; run
|
|
433
463
|
|
|
434
464
|
testem launchers
|
|
435
465
|
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
If you want to debug tests in PhantomJS, include the `phantomjs_debug_port` option in your testem configuration, referencing an available port number. Once testem has started PhantomJS, navigate (with a traditional browser) to http://localhost:<port> and attach to one of PhantomJS's browser tabs (probably the second one in the list). `debugger` statements will now break in the debugging console.
|
|
439
|
-
|
|
440
|
-
If you want to use any of the [PhantomJS command line options](http://phantomjs.org/api/command-line.html), include the `phantomjs_args` option in your testem configuration. For example:
|
|
441
|
-
|
|
442
|
-
```javascript
|
|
443
|
-
"phantomjs_args": [
|
|
444
|
-
"--ignore-ssl-errors=true"
|
|
445
|
-
]
|
|
446
|
-
```
|
|
447
|
-
|
|
448
|
-
You can also customize the phantomjs launcher file by specifying the `phantomjs_launch_script` option.
|
|
449
|
-
In this launcher you can change options like the `viewPortSize`. See `assets/phantom.js` for the default launcher.
|
|
450
|
-
|
|
451
|
-
Preprocessors (CoffeeScript, LESS, Sass, Browserify, etc)
|
|
452
|
-
---------------------------------------------------------
|
|
453
|
-
|
|
454
|
-
If you need to run a preprocessor (or indeed any shell command before the start of the tests) use the `before_tests` option, such as
|
|
466
|
+
and confirm **Headless Chrome** appears.
|
|
455
467
|
|
|
456
|
-
|
|
468
|
+
Select it like any other launcher, for example:
|
|
457
469
|
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
"*.coffee"
|
|
463
|
-
]
|
|
470
|
+
```json
|
|
471
|
+
{
|
|
472
|
+
"launch_in_ci": ["Headless Chrome"]
|
|
473
|
+
}
|
|
464
474
|
```
|
|
465
475
|
|
|
466
|
-
|
|
476
|
+
To add or override flags, use **`browser_args`** (see [`docs/browser_args.md`](docs/browser_args.md)). Testem merges these with the built-in headless arguments—for example a fixed remote-debugging port for attaching DevTools:
|
|
467
477
|
|
|
468
|
-
```
|
|
469
|
-
|
|
470
|
-
"
|
|
471
|
-
]
|
|
478
|
+
```json
|
|
479
|
+
{
|
|
480
|
+
"browser_args": {
|
|
481
|
+
"Headless Chrome": ["--remote-debugging-port=9222"]
|
|
482
|
+
}
|
|
483
|
+
}
|
|
472
484
|
```
|
|
473
485
|
|
|
474
|
-
|
|
486
|
+
**Remote debugging:** By default the headless launcher passes **`--remote-debugging-port=0`**, so Chrome chooses a random port—set a **fixed** port in `browser_args` (as in the example above) so you can connect reliably. With Testem running, open a regular Chrome window to **`chrome://inspect`**, use **Configure…** under “Discover network targets” to add **`localhost:9222`** (or whatever port you set), find your test page under **Remote Target**, and click **inspect**. You can also open **`http://localhost:9222`** and follow the links to a target page. **`debugger`** statements and breakpoints work in the DevTools **Sources** panel.
|
|
475
487
|
|
|
476
|
-
|
|
488
|
+
**Headless Chrome Beta** is available when the Chrome Beta channel is installed. For legacy **PhantomJS**-specific options (`phantomjs_args`, `phantomjs_debug_port`, etc.), see [`docs/config_file.md`](docs/config_file.md).
|
|
477
489
|
|
|
478
|
-
|
|
479
|
-
"after_tests": "rm *.js"
|
|
480
|
-
```
|
|
481
|
-
|
|
482
|
-
If you would prefer simply to clean up when Testem exits, you can use the `on_exit` option.
|
|
490
|
+
**Internet Explorer** and the legacy **PhantomJS** launcher are still available, but we document them as **deprecated** targets: keeping them viable through transpilation and polyfills is likely to get more difficult over time, so prefer evergreen browsers, **Chrome** with `--headless` for headless automation, or Node for new projects. See the [configuration reference](docs/config_file.md) for how we categorize browsers.
|
|
483
491
|
|
|
484
492
|
Running browser code after tests complete
|
|
485
493
|
-------------
|
|
@@ -517,7 +525,7 @@ Sometimes you may want to re-map a URL to a different directory on the file syst
|
|
|
517
525
|
+ public
|
|
518
526
|
+ tests.html
|
|
519
527
|
|
|
520
|
-
Let's say you want to serve `tests.html` at the top level url `/tests.html`, all the
|
|
528
|
+
Let's say you want to serve `tests.html` at the top level url `/tests.html`, all the JavaScript files under `/js` and all the css under `/css`. You can use the "routes" option to do that
|
|
521
529
|
|
|
522
530
|
```javascript
|
|
523
531
|
"routes": {
|
|
@@ -543,7 +551,7 @@ And then make sure you include the adapter code in your test suite and you are r
|
|
|
543
551
|
Native notifications
|
|
544
552
|
--------------------------------
|
|
545
553
|
|
|
546
|
-
If you'd prefer not to be looking at the terminal while developing, you can enable native notifications (e.g.
|
|
554
|
+
If you'd prefer not to be looking at the terminal while developing, you can enable native notifications (e.g. Notification Center on macOS) using the `-g` option.
|
|
547
555
|
|
|
548
556
|
API Proxy
|
|
549
557
|
--------------------------------
|
|
@@ -568,77 +576,110 @@ Simply add a `proxies` section to the `testem.json` configuration file.
|
|
|
568
576
|
```
|
|
569
577
|
|
|
570
578
|
This functionality is implemented as a *transparent proxy*, hence a request to
|
|
571
|
-
`http://localhost:7357/api/posts.json` will be proxied to `http://localhost:4200/api/posts.json` without removing the `/api` prefix. Setting the `secure` option to `false` as in the above `/xmlapi` configuration block will ignore TLS certificate validation and allow tests to successfully reach that URL even if testem was launched over HTTP. Other available options can be found here: https://github.com/
|
|
579
|
+
`http://localhost:7357/api/posts.json` will be proxied to `http://localhost:4200/api/posts.json` without removing the `/api` prefix. Setting the `secure` option to `false` as in the above `/xmlapi` configuration block will ignore TLS certificate validation and allow tests to successfully reach that URL even if testem was launched over HTTP. Other available options can be found here: https://github.com/http-party/node-http-proxy#options
|
|
572
580
|
|
|
573
581
|
To limit the functionality to only certain content types, use "onlyContentTypes".
|
|
574
582
|
|
|
583
|
+
Preprocessors (Babel, TypeScript, LESS, Sass, Browserify, CoffeeScript, etc)
|
|
584
|
+
---------------------------------------------------------
|
|
585
|
+
|
|
586
|
+
If you need to run a preprocessor (or indeed any shell command before the start of the tests) use the `before_tests` option, such as
|
|
587
|
+
|
|
588
|
+
"before_tests": "coffee -c *.coffee"
|
|
589
|
+
|
|
590
|
+
or, with Babel (see the [Babel example](https://github.com/testem/testem/tree/master/examples/babel)):
|
|
591
|
+
|
|
592
|
+
"before_tests": "babel src --out-dir ."
|
|
593
|
+
|
|
594
|
+
or, with a `tsconfig.json` that emits JavaScript next to your project (see the [TypeScript example](https://github.com/testem/testem/tree/master/examples/typescript)):
|
|
595
|
+
|
|
596
|
+
"before_tests": "tsc"
|
|
597
|
+
|
|
598
|
+
And Testem will run it before each test run. Point **`src_files`** at the sources you want
|
|
599
|
+
watched (see **File watching** under Development Mode above).
|
|
600
|
+
|
|
601
|
+
```javascript
|
|
602
|
+
"src_files": [
|
|
603
|
+
"*.coffee"
|
|
604
|
+
]
|
|
605
|
+
```
|
|
606
|
+
|
|
607
|
+
Since you want to be serving the `.js` files that are generated and not the `.coffee` files, you want to specify the `serve_files` option to tell it that
|
|
608
|
+
|
|
609
|
+
```javascript
|
|
610
|
+
"serve_files": [
|
|
611
|
+
"*.js"
|
|
612
|
+
]
|
|
613
|
+
```
|
|
614
|
+
|
|
615
|
+
Testem will throw up a big ol' error dialog if the preprocessor command exits with an error code, so code checkers like JSHint or ESLint can be used here as well.
|
|
616
|
+
|
|
617
|
+
If you need to run a command after your tests have completed (such as removing compiled `.js` files), use the `after_tests` option.
|
|
618
|
+
|
|
619
|
+
```javascript
|
|
620
|
+
"after_tests": "rm *.js"
|
|
621
|
+
```
|
|
622
|
+
|
|
623
|
+
If you would prefer simply to clean up when Testem exits, you can use the `on_exit` option.
|
|
624
|
+
|
|
575
625
|
Example Projects
|
|
576
626
|
----------------
|
|
577
627
|
|
|
578
628
|
I've created [examples](https://github.com/testem/testem/tree/master/examples/) for various setups
|
|
579
629
|
|
|
630
|
+
* [Vite (middleware + plugin)](https://github.com/testem/testem/tree/master/examples/vite)
|
|
631
|
+
* [Electron](https://github.com/testem/testem/tree/master/examples/electron)
|
|
632
|
+
* [TypeScript Project](https://github.com/testem/testem/tree/master/examples/typescript)
|
|
633
|
+
* [ESLint Example](https://github.com/testem/testem/tree/master/examples/eslint)
|
|
634
|
+
* [Babel Project](https://github.com/testem/testem/tree/master/examples/babel)
|
|
580
635
|
* [Simple QUnit project](https://github.com/testem/testem/tree/master/examples/qunit_simple)
|
|
581
636
|
* [Simple Jasmine project](https://github.com/testem/testem/tree/master/examples/jasmine_simple)
|
|
582
637
|
* [Jasmine 2](https://github.com/testem/testem/tree/master/examples/jasmine2)
|
|
583
638
|
* [Custom Jasmine project](https://github.com/testem/testem/tree/master/examples/jasmine_custom)
|
|
584
|
-
* [Custom Jasmine project using Require.js](https://github.com/testem/testem/tree/master/examples/jasmine_requirejs)
|
|
585
639
|
* [Simple Mocha Project](https://github.com/testem/testem/tree/master/examples/mocha_simple)
|
|
586
640
|
* [Mocha + Chai](https://github.com/testem/testem/tree/master/examples/mocha_chai_simple)
|
|
587
641
|
* [Hybrid Project](https://github.com/testem/testem/tree/master/examples/hybrid_simple) - Mocha tests running in both the browser and Node.
|
|
588
|
-
* [Coffeescript Project](https://github.com/testem/testem/tree/master/examples/coffeescript)
|
|
589
|
-
* [Browserify Project](https://github.com/testem/testem/tree/master/examples/browserify)
|
|
590
|
-
* [JSHint Example](https://github.com/testem/testem/tree/master/examples/jshint)
|
|
591
642
|
* [Custom Test Framework](https://github.com/testem/testem/tree/master/examples/custom_adapter)
|
|
592
643
|
* [Tape Example](https://github.com/testem/testem/tree/master/examples/tape_example)
|
|
593
|
-
* [
|
|
594
|
-
* [
|
|
595
|
-
* [
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
644
|
+
* [Browserify Project](https://github.com/testem/testem/tree/master/examples/browserify)
|
|
645
|
+
* [JSHint Example](https://github.com/testem/testem/tree/master/examples/jshint)
|
|
646
|
+
* [Coffeescript Project](https://github.com/testem/testem/tree/master/examples/coffeescript)
|
|
647
|
+
* [Custom Jasmine project using Require.js](https://github.com/testem/testem/tree/master/examples/jasmine_requirejs)
|
|
648
|
+
* [BrowserStack Integration](https://github.com/testem/testem/tree/master/examples/browserstack)
|
|
649
|
+
* [SauceLabs Integration](https://github.com/testem/testem/tree/master/examples/saucelabs)
|
|
650
|
+
* [Code Coverage with Istanbul](https://github.com/testem/testem/tree/master/examples/coverage_istanbul)
|
|
599
651
|
|
|
600
|
-
|
|
652
|
+
Historical Screencasts
|
|
653
|
+
----------------------
|
|
601
654
|
|
|
602
|
-
|
|
655
|
+
These YouTube screencasts are from around **2012** and may not match the current UI or features, but they still illustrate the core ideas:
|
|
603
656
|
|
|
604
|
-
|
|
657
|
+
* **[Introductory screencast (11:39)](https://www.youtube.com/watch?v=-1mjv4yk5JM)** — TDD workflow
|
|
658
|
+
* **[Launchers (12:10)](https://www.youtube.com/watch?v=Up0lVjWk9Rk)** — auto-launch and running tests in **Node**
|
|
659
|
+
* **[CI mode (4:24)](https://www.youtube.com/watch?v=Js16Cj80HKY)** — continuous integration
|
|
605
660
|
|
|
606
661
|
Contributing
|
|
607
662
|
------------
|
|
608
663
|
|
|
609
664
|
If you want to [contribute to the project](https://github.com/testem/testem/blob/master/CONTRIBUTING.md), I am going to do my best to stay out of your way.
|
|
610
665
|
|
|
611
|
-
Roadmap
|
|
612
|
-
-------
|
|
613
|
-
|
|
614
|
-
1. [BrowserStack](http://www.browserstack.com/user/dashboard) integration - following [Bunyip](http://www.thecssninja.com/javascript/bunyip)'s example
|
|
615
|
-
2. Figure out a happy path for testing on mobile browsers (maybe BrowserStack).
|
|
616
|
-
|
|
617
666
|
Core Maintainer(s)
|
|
618
667
|
------------------
|
|
619
668
|
|
|
620
669
|
* [Johannes Würbach](https://github.com/johanneswuerbach)
|
|
621
670
|
|
|
622
|
-
Community
|
|
623
|
-
---------
|
|
624
|
-
|
|
625
|
-
* **Mailing list**: <https://groups.google.com/forum/?fromgroups#!forum/testem-users>
|
|
626
|
-
|
|
627
671
|
Credits
|
|
628
672
|
-------
|
|
629
673
|
|
|
630
674
|
Testem depends on the following great software
|
|
631
675
|
|
|
632
|
-
* [Jasmine](
|
|
633
|
-
* [QUnit](
|
|
634
|
-
* [Mocha](
|
|
635
|
-
* [Node](
|
|
636
|
-
* [Socket.IO](
|
|
637
|
-
* [
|
|
638
|
-
* [
|
|
639
|
-
* [
|
|
640
|
-
* [Node Commander](http://tjholowaychuk.com/post/9103188408/commander-js-nodejs-command-line-interfaces-made-easy)
|
|
676
|
+
* [Jasmine](https://jasmine.github.io/)
|
|
677
|
+
* [QUnit](https://qunitjs.com/)
|
|
678
|
+
* [Mocha](https://mochajs.org/)
|
|
679
|
+
* [Node](https://nodejs.org/)
|
|
680
|
+
* [Socket.IO](https://socket.io/)
|
|
681
|
+
* [tap-parser](https://github.com/tapjs/tap-parser)
|
|
682
|
+
* [Charm](https://github.com/aheckmann/charm)
|
|
683
|
+
* [Commander.js](https://github.com/tj/commander.js)
|
|
641
684
|
* [JS-Yaml](https://github.com/nodeca/js-yaml)
|
|
642
|
-
* [Express](
|
|
643
|
-
* [jQuery](http://jquery.com/)
|
|
644
|
-
* [Backbone](http://backbonejs.org/)
|
|
685
|
+
* [Express](https://expressjs.com/)
|
package/lib/api.js
CHANGED
|
@@ -10,7 +10,7 @@ const Server = require('./server');
|
|
|
10
10
|
/*
|
|
11
11
|
CLI-level options:
|
|
12
12
|
|
|
13
|
-
file: [String] configuration file (
|
|
13
|
+
file: [String] configuration file path (JSON, YAML, JS: testem.js / .cjs / .mjs and dotted variants)
|
|
14
14
|
host: [String] server host to use (localhost)
|
|
15
15
|
port: [Number] server port to use (7357)
|
|
16
16
|
launch: [Array] list of launchers to use for current runs (defaults to current mode)
|