Skip to content

Commit d53ed78

Browse files
authored
fix(wasm): Ensure browser bundle exists before running tests (#4389)
The tests in our `wasm` package use the browser bundle, and therefore won't run if the bundle hasn't been built. #4074 added a warning for this situation. This improves that by actually building the missing bundles, ensuring the tests will always run.
1 parent e52faa4 commit d53ed78

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

packages/wasm/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"lint:eslint": "eslint . --cache --cache-location '../../eslintcache/' --format stylish",
5656
"lint:prettier": "prettier --check \"{src,test}/**/*.ts\"",
5757
"pack": "npm pack",
58-
"test": "cross-env PORT=1337 jest",
58+
"test": "node test/scripts/ensure-browser-bundle.js && cross-env PORT=1337 jest",
5959
"test:watch": "jest --watch"
6060
},
6161
"volta": {

packages/wasm/test/integration.test.js

-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
11
/* global page, window */
2-
const fs = require('fs');
3-
const path = require('path');
42

53
const HOST = `http://localhost:${process.env.PORT}`;
64

7-
if (!fs.existsSync(path.resolve(__dirname, '../../browser/build/bundle.js'))) {
8-
throw new Error(
9-
'ERROR: No browser bundle found in `packages/browser/build/`. Please run `yarn build` in the browser package before running wasm tests.',
10-
);
11-
}
12-
135
describe('Wasm', () => {
146
it('captured exception should include modified frames and debug_meta attribute', async () => {
157
await page.goto(HOST);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
const { execSync } = require('child_process');
4+
5+
function ensureBrowserBundle() {
6+
const browserPackageDir = path.resolve(__dirname, '../../../browser');
7+
if (!fs.existsSync(path.resolve(browserPackageDir, 'build/bundle.js'))) {
8+
// eslint-disable-next-line no-console
9+
console.warn('\nWARNING: Missing browser bundle. Bundle will be created before running wasm integration tests.');
10+
execSync(`pushd ${browserPackageDir} && yarn build:bundle && popd`);
11+
}
12+
}
13+
14+
ensureBrowserBundle();

0 commit comments

Comments
 (0)