diff --git a/test/fixtures/devtools-extension/content.js b/test/fixtures/devtools-extension/content.js index 5af9ae9..01f6f90 100644 --- a/test/fixtures/devtools-extension/content.js +++ b/test/fixtures/devtools-extension/content.js @@ -1,4 +1,6 @@ -test("devtools.inspectedWindow.eval resolved with an error result", async (t) => { +test("devtools.inspectedWindow.eval resolved with an error result", { + timeout: 5000, +}, async (t) => { const {evalResult} = await browser.runtime.sendMessage({ apiMethod: "devtools.inspectedWindow.eval", params: ["throw new Error('fake error');"], @@ -14,7 +16,9 @@ test("devtools.inspectedWindow.eval resolved with an error result", async (t) => "the second element value property should include the expected error message"); }); -test("devtools.inspectedWindow.eval resolved without an error result", async (t) => { +test("devtools.inspectedWindow.eval resolved without an error result", { + timeout: 5000, +}, async (t) => { const {evalResult} = await browser.runtime.sendMessage({ apiMethod: "devtools.inspectedWindow.eval", params: ["[document.documentElement.localName]"], diff --git a/test/fixtures/tape-standalone.js b/test/fixtures/tape-standalone.js index 1face23..710bfd9 100644 --- a/test/fixtures/tape-standalone.js +++ b/test/fixtures/tape-standalone.js @@ -10,9 +10,30 @@ if (navigator.userAgent.includes("Chrome/")) { } // Export as a global a wrapped test function which enforces a timeout by default. -window.test = (desc, fn) => { - tape(`${desc} (${browser})`, async (t) => { - t.timeoutAfter(DEFAULT_TIMEOUT); +/** + * @param {string} desc + * The test description + * @param {object} [options] + * The test options, can be omitted. + * @param {number} [options.timeout=DEFAULT_TIMEOUT] + * The time after which the test fails automatically, unless it has already passed. + * @param {boolean} [options.skip] + * Whether the test case should be skipped. + * @param {function(tape.Test):(void|Promise)} fn + * The test case function, takes the test object as a callback. + */ +window.test = (desc, options, fn) => { + if (typeof options === "function") { + // Allow swapping options with fn + [fn, options] = [options, fn]; + } + + options = { + timeout: DEFAULT_TIMEOUT, + ...options, + }; + + tape(`${desc} (${browser})`, options, async (t) => { await fn(t); }); }; diff --git a/test/integration/setup.js b/test/integration/setup.js index 7a4665d..40af6c1 100644 --- a/test/integration/setup.js +++ b/test/integration/setup.js @@ -165,6 +165,7 @@ test.onFailure(() => { * @param {string} parameters.description * @param {string[]} parameters.extensions * @param {boolean|string|string[]} [parameters.skip] + * @param {boolean} [parameters.openDevTools] */ const defineExtensionTests = ({description, extensions, skip, openDevTools}) => { for (const extensionDirName of extensions) { @@ -192,8 +193,8 @@ const defineExtensionTests = ({description, extensions, skip, openDevTools}) => path.join(__dirname, "..", "fixtures", extensionDirName)); const srcPolyfill = path.join(__dirname, "..", "..", "dist", "browser-polyfill.js"); - const tmpDir = tmp.dirSync({unsafeCleanup: true}); - const extensionPath = path.join(tmpDir.name, extensionDirName); + tempDir = tmp.dirSync({unsafeCleanup: true}); + const extensionPath = path.join(tempDir.name, extensionDirName); cp("-rf", srcExtensionPath, extensionPath); cp("-f", srcPolyfill, extensionPath);