Skip to content

Commit

Permalink
Fix jasmine runs for local testing and tape runs on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
EvHaus committed Mar 3, 2024
1 parent fa59a0d commit 99f17c2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ hyperfine --warmup 1 \
## Suites

- `jasmine`: This is our baseline, using Jasmine and happy-dom.
- *NOTE*: Jasmine doesn't support shapshot testing so those tests do a basic comparison
- *NOTE*: Jasmine doesn't support shapshot testing so those tests do a basic object comparison
- `bun`: Same test suite, but running using Bun.
- `jest`: Same test suite, but running using Jest.
- `tape`: Same test suite, but running using Tape and ts-node.
- *NOTE*: Tape doesn't support shapshot testing so those tests do a basic comparison
- *NOTE*: Tape doesn't support shapshot testing so those tests do a basic object comparison
- `vitest`: Same test suite, but running using Vitest. *NOTE*: That benchmarks use `--poolOptions.threads.isolate=false` as it has the best performance (see [this comment](https://github.com/vitest-dev/vitest/issues/579#issuecomment-1946462435))

## Results
Expand Down
9 changes: 6 additions & 3 deletions benchmarks/jasmine/spec/helpers/happydom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ global.window = window;
// Register global window extensions
[
'document',
// NOTE: This is need for running tests on GitHub Actions CI, but causes
// failure on local builds due to this error:
// > Cannot set property navigator of #<Object> which has only a getter
'navigator',
'Element',
'getComputedStyle',
Expand All @@ -19,5 +16,11 @@ global.window = window;
try {
global[key] = global.window[key];
} catch (e) {
// NOTE: This is need for running tests on GitHub Actions CI, but causes
// failure on local builds due to this error:
// > Cannot set property navigator of #<Object> which has only a getter
if (!e.message.includes('Cannot set property navigator')) {
throw e;
}
}
});
12 changes: 11 additions & 1 deletion benchmarks/tape/helpers/happydom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,20 @@ global.window = window;
// Register global window extensions
[
'document',
'navigator',
'Element',
'getComputedStyle',
'HTMLElement',
'SVGElement'
].forEach((key) => {
global[key] = global.window[key];
try {
global[key] = global.window[key];
} catch (e) {
// NOTE: This is need for running tests on GitHub Actions CI, but causes
// failure on local builds due to this error:
// > Cannot set property navigator of #<Object> which has only a getter
if (!e.message.includes('Cannot set property navigator')) {
throw e;
}
}
});

0 comments on commit 99f17c2

Please sign in to comment.