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

Commit

Permalink
Set up tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MattiasBuelens committed Mar 12, 2021
1 parent 770a58d commit 35cb5db
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
5 changes: 4 additions & 1 deletion package.json
Expand Up @@ -4,7 +4,7 @@
"description": "WIP support for WHATWG Stream in Node",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "node --expose-internals --expose_gc test/wpt/test.js"
},
"repository": {
"type": "git",
Expand All @@ -16,6 +16,9 @@
"url": "https://github.com/nodejs/whatwg-stream/issues"
},
"homepage": "https://github.com/nodejs/whatwg-stream#readme",
"engines": {
"node": ">= 15"
},
"dependencies": {
"web-streams-polyfill": "^3.0.2"
}
Expand Down
14 changes: 14 additions & 0 deletions test/wpt/status/streams.json
@@ -0,0 +1,14 @@
{
"piping/pipe-through.any.js": {
"fail": "Node does not perform a brand check for AbortSignal.prototype.aborted"
},
"queuing-strategies-size-function-per-global.window.js": {
"skip": "test requires an <iframe>"
},
"readable-byte-streams/bad-buffers-and-views.any.js": {
"skip": "Node does not have detached ArrayBuffers"
},
"transferable/deserialize-error.window.js": {
"skip": "test requires an <iframe>"
}
}
30 changes: 30 additions & 0 deletions test/wpt/test.js
@@ -0,0 +1,30 @@
'use strict';

// Flags: --expose-internals --expose_gc
// Note:
// - The --expose-internals flag is specific to Node.js core's
// internal error system and is unnecessary for external users.
// - The --expose_gc flag is specific to the WPT stream tests

const { WPTRunner } = require('../common/wpt');
const runner = new WPTRunner('streams');
const whatwgStreamPath = require.resolve('../../');

runner.setFlags(['--expose-internals']);

runner.setInitScript(`
const { internalBinding } = require('internal/test/binding');
const { DOMException } = internalBinding('messaging');
global.DOMException = DOMException;
const whatwgStream = require(${JSON.stringify(whatwgStreamPath)});
for (const [name, value] of Object.entries(whatwgStream)) {
Object.defineProperty(global, name, {
value,
writable: true,
configurable: true
});
}
`);

runner.runJsTests();

0 comments on commit 35cb5db

Please sign in to comment.