Skip to content

Commit b709f6f

Browse files
authored
Merge pull request #120 from nolanlawson/refactor-tests
Switch WPT tests to `node:test` runner
2 parents 9b2f7b5 + a40ef06 commit b709f6f

File tree

195 files changed

+510
-68
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

195 files changed

+510
-68
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
"test-mocha": "mocha --timeout 10000 build/esm/test/fakeIndexedDB",
9595
"build-qunit": "mkdir build/esm/test/indexedDBmock && cp src/test/indexedDBmock/* build/esm/test/indexedDBmock && browserify src/test/indexedDBmock/exports-qunit-bundle.js -o build/esm/test/indexedDBmock/exports-qunit-bundle.js -t [ babelify --presets [ @babel/preset-env ] ]",
9696
"test-qunit": "pnpm run build-qunit && OPENSSL_CONF=/dev/null node-qunit-phantomjs build/esm/test/indexedDBmock/index.html",
97-
"test-w3c": "node src/test/web-platform-tests/run-all.js",
97+
"test-w3c": "node --test src/test/web-platform-tests/run-all.js",
9898
"test": "pnpm run lint && pnpm run build && pnpm run test-jest && node test/test.js && node test/dexie.js && pnpm run test-w3c && pnpm run test-mocha && pnpm run test-qunit",
9999
"prepare": "husky"
100100
},

src/test/web-platform-tests/README.md

Lines changed: 17 additions & 0 deletions

src/test/web-platform-tests/convert.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,19 @@ const outFolder = path.posix.join(__dirname, "converted");
134134
codeChunks.push(declareGlobalVars);
135135
}
136136

137+
if (testScript.includes("title=")) {
138+
console.log("found!");
139+
}
140+
const titleMatches = [
141+
...testScript.matchAll(/\/\/\s*META:\s*title=(.+)$/gm),
142+
];
143+
if (titleMatches.length) {
144+
// some tests use `self.title` to create the test name
145+
codeChunks.push(
146+
`globalThis.title = ${JSON.stringify(titleMatches[0][1])};\n`,
147+
);
148+
}
149+
137150
const importMatches = testScript
138151
.matchAll(/^\/\/\s*META:\s*script=(.+)$/gm)
139152
.filter(

src/test/web-platform-tests/converted/abort-in-initial-upgradeneeded.any.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import "../wpt-env.js";
22

33
let attrs,cursor,db,store,store2;
44

5+
globalThis.title = "IndexedDB";
6+
57
/* Delete created databases
68
*
79
* Go through each finished test, see if it has an associated database. Close

src/test/web-platform-tests/converted/bindings-inject-keys-bypass.any.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import "../wpt-env.js";
22

33
let attrs,cursor,db,store,store2;
44

5+
globalThis.title = "IndexedDB: ES bindings - Inject a key into a value - Keys bypass setters";
6+
57
'use strict';
68

79
// Returns an IndexedDB database name that is unique to the test case.

src/test/web-platform-tests/converted/bindings-inject-values-bypass.any.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import "../wpt-env.js";
22

33
let attrs,cursor,db,store,store2;
44

5+
globalThis.title = "IndexedDB: ES bindings - Inject a key into a value - Values bypass chain and setters";
6+
57
'use strict';
68

79
// Returns an IndexedDB database name that is unique to the test case.

src/test/web-platform-tests/converted/blob-composite-blob-reads.any.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import "../wpt-env.js";
22

33
let attrs,cursor,db,store,store2;
44

5+
globalThis.title = "IDB-backed composite blobs maintain coherency";
6+
57
'use strict';
68

79
// Returns an IndexedDB database name that is unique to the test case.

src/test/web-platform-tests/converted/blob-contenttype.any.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import "../wpt-env.js";
22

33
let attrs,cursor,db,store,store2;
44

5+
globalThis.title = "Blob Content Type";
6+
57
/* Delete created databases
68
*
79
* Go through each finished test, see if it has an associated database. Close

src/test/web-platform-tests/converted/blob-delete-objectstore-db.any.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import "../wpt-env.js";
22

33
let attrs,cursor,db,store,store2;
44

5+
globalThis.title = "Blob Delete Object Store";
6+
57
/* Delete created databases
68
*
79
* Go through each finished test, see if it has an associated database. Close

src/test/web-platform-tests/converted/blob-valid-after-abort.any.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import "../wpt-env.js";
22

33
let attrs,cursor,db,store,store2;
44

5+
globalThis.title = "Blob Valid After Abort";
6+
57
/* Delete created databases
68
*
79
* Go through each finished test, see if it has an associated database. Close

0 commit comments

Comments
 (0)