test(devtools): Fix intermittent DevTools API test timeout (#177)
This commit is contained in:
parent
949f08cc7d
commit
3aad2418d8
|
@ -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]"],
|
||||
|
|
|
@ -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<void>)} 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);
|
||||
});
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue