Skip to content
This repository was archived by the owner on Jul 28, 2021. It is now read-only.

Commit 35cb5db

Browse files
Set up tests
1 parent 770a58d commit 35cb5db

3 files changed

Lines changed: 48 additions & 1 deletion

File tree

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "WIP support for WHATWG Stream in Node",
55
"main": "index.js",
66
"scripts": {
7-
"test": "echo \"Error: no test specified\" && exit 1"
7+
"test": "node --expose-internals --expose_gc test/wpt/test.js"
88
},
99
"repository": {
1010
"type": "git",
@@ -16,6 +16,9 @@
1616
"url": "https://github.com/nodejs/whatwg-stream/issues"
1717
},
1818
"homepage": "https://github.com/nodejs/whatwg-stream#readme",
19+
"engines": {
20+
"node": ">= 15"
21+
},
1922
"dependencies": {
2023
"web-streams-polyfill": "^3.0.2"
2124
}

test/wpt/status/streams.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"piping/pipe-through.any.js": {
3+
"fail": "Node does not perform a brand check for AbortSignal.prototype.aborted"
4+
},
5+
"queuing-strategies-size-function-per-global.window.js": {
6+
"skip": "test requires an <iframe>"
7+
},
8+
"readable-byte-streams/bad-buffers-and-views.any.js": {
9+
"skip": "Node does not have detached ArrayBuffers"
10+
},
11+
"transferable/deserialize-error.window.js": {
12+
"skip": "test requires an <iframe>"
13+
}
14+
}

test/wpt/test.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
'use strict';
2+
3+
// Flags: --expose-internals --expose_gc
4+
// Note:
5+
// - The --expose-internals flag is specific to Node.js core's
6+
// internal error system and is unnecessary for external users.
7+
// - The --expose_gc flag is specific to the WPT stream tests
8+
9+
const { WPTRunner } = require('../common/wpt');
10+
const runner = new WPTRunner('streams');
11+
const whatwgStreamPath = require.resolve('../../');
12+
13+
runner.setFlags(['--expose-internals']);
14+
15+
runner.setInitScript(`
16+
const { internalBinding } = require('internal/test/binding');
17+
const { DOMException } = internalBinding('messaging');
18+
global.DOMException = DOMException;
19+
20+
const whatwgStream = require(${JSON.stringify(whatwgStreamPath)});
21+
for (const [name, value] of Object.entries(whatwgStream)) {
22+
Object.defineProperty(global, name, {
23+
value,
24+
writable: true,
25+
configurable: true
26+
});
27+
}
28+
`);
29+
30+
runner.runJsTests();

0 commit comments

Comments
 (0)