Skip to content

Commit

Permalink
test: only include WebSocket in WPT Report where it's landed (#2351)
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Oct 17, 2023
1 parent 40ab050 commit 52a7989
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"test:tdd": "tap test/*.js test/diagnostics-channel/*.js -w",
"test:typescript": "node scripts/verifyVersion.js 14 || tsd && tsc --skipLibCheck test/imports/undici-import.ts",
"test:websocket": "node scripts/verifyVersion.js 18 || tap test/websocket/*.js",
"test:wpt": "node scripts/verifyVersion 18 || (node test/wpt/start-fetch.mjs && node test/wpt/start-FileAPI.mjs && node test/wpt/start-mimesniff.mjs && node test/wpt/start-xhr.mjs && node --no-warnings test/wpt/start-websockets.mjs)",
"test:wpt": "node scripts/verifyVersion 18 || (node test/wpt/start-fetch.mjs && node test/wpt/start-FileAPI.mjs && node test/wpt/start-mimesniff.mjs && node test/wpt/start-xhr.mjs && node --no-warnings --expose-internals test/wpt/start-websockets.mjs)",
"coverage": "nyc --reporter=text --reporter=html npm run test",
"coverage:ci": "nyc --reporter=lcov npm run test",
"bench": "PORT=3042 concurrently -k -s first npm:bench:server npm:bench:run",
Expand Down
11 changes: 10 additions & 1 deletion test/wpt/start-websockets.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,18 @@ import { join } from 'path'
import { fileURLToPath } from 'url'
import { fork } from 'child_process'
import { on } from 'events'
import options from 'internal/options'

const { WPT_REPORT } = process.env

function isGlobalAvailable () {
if (typeof WebSocket !== 'undefined') {
return true
}

return typeof options.getOptionValue('--experimental-websocket') === 'boolean'
}

if (process.env.CI) {
// TODO(@KhafraDev): figure out *why* these tests are flaky in the CI.
// process.exit(0)
Expand All @@ -22,7 +31,7 @@ child.on('exit', (code) => process.exit(code))
for await (const [message] of on(child, 'message')) {
if (message.server) {
const runner = new WPTRunner('websockets', message.server, {
appendReport: !!WPT_REPORT,
appendReport: !!WPT_REPORT && isGlobalAvailable(),
reportPath: WPT_REPORT
})
runner.run()
Expand Down

0 comments on commit 52a7989

Please sign in to comment.