Skip to content

Commit 442c0a0

Browse files
lobsterkatieLms24
authored andcommitted
feat(browser): Add debugging hints to browser integration tests (#4914)
Our old browser integration tests are difficult to debug. This adds a file of (hard-won) debugging tips to the test directory, to hopefully make it easier on the next person. While it's true that it contains a lot of very specific references (to functions, files, etc) and is therefore much more susceptible to becoming out of date, these tests aren't something we change often, and the consequences of such staleness are small.
1 parent 113a55b commit 442c0a0

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
### Debugging Hints
2+
3+
These tests are hard to debug, because the testing system is somewhat complex, straightforward debugging doesn't work (see below), and the output of most `console.log` calls gets swallowed. Here, future debugger, are some tips to make it easier, to hopefully save you the hour(s) of trial and error it took to figure them out.
4+
5+
- `suites/shell.js`:
6+
- Remove the loader options from the `variants` array.
7+
- Delete all of the placeholders of the form `{{ suites/something.js }}` except for the one you're interested in. It's not enough to comment them out, because they'll still exist in the file and get replaced by the test runner. Don't forget the one at the bottom of the file.
8+
9+
- `suites/helpers.js`:
10+
- Add `sandbox.contentWindow.console.log = (...args) => console.log(...args);` just before the return in `createSandbox()`. This will make it so that `console.log` statements come through to the terminal. (Yes, Karma theoretically has settings for that, but they don't seem to work. See https://github.com/karma-runner/karma-mocha/issues/47.)
11+
12+
- `suites.yourTestFile.js`:
13+
- Use `it.only` to only run the single test you're interested in.
14+
15+
- Repo-level `rollup.config.js`:
16+
- Comment out all bundle variants except whichever one `run.js` is turning into `artifacts/sdk.js`.
17+
18+
- Browser-package-level `rollup.config.js`:
19+
- Build only one of `es5` and `es6`.
20+
21+
- Run `build:bundle:watch` in a separate terminal tab, so that when you add `console.log`s to the SDK, they get picked up.
22+
23+
- Don't bother trying to copy one of our standard VSCode debug profiles, because it won't work, except to debug the testing system itself. (It will pause the node process running the tests, not the headless browser in which the tests themselves run.)
24+
25+
- To make karma do verbose logging, run `export DEBUG=1`. To turn it off, run `unset DEBUG`.
26+
27+
- To make the testing system do verbose logging, run `yarn test:integration --debug`.
28+
29+
- To see exactly the files which are being run, comment out `rmdir('artifacts');` near the bottom of `run.js`.

packages/browser/test/integration/suites/shell.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function runVariant(variant) {
2020
});
2121

2222
/**
23-
* This part will be replaced by the test runner
23+
* The test runner will replace each of these placeholders with the contents of the corresponding file.
2424
*/
2525
{{ suites/config.js }} // prettier-ignore
2626
{{ suites/api.js }} // prettier-ignore

0 commit comments

Comments
 (0)