From 9a0c283ae2ebb7321b8f46a97178e5e284b02da4 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Sun, 26 Sep 2021 17:22:54 +0900 Subject: Move to jest on e2e test --- e2e/blacklist.test.ts | 4 ++-- e2e/clipboard.test.ts | 4 ++-- e2e/colorscheme.test.ts | 4 ++-- e2e/command_addbookmark.test.ts | 4 ++-- e2e/command_bdelete.test.ts | 4 ++-- e2e/command_buffer.test.ts | 4 ++-- e2e/command_help.test.ts | 4 ++-- e2e/command_open.test.ts | 4 ++-- e2e/command_quit.test.ts | 4 ++-- e2e/command_tabopen.test.ts | 4 ++-- e2e/command_winopen.test.ts | 4 ++-- e2e/completion.test.ts | 4 ++-- e2e/completion_buffers.test.ts | 4 ++-- e2e/completion_open.test.ts | 4 ++-- e2e/completion_set.test.ts | 4 ++-- e2e/console.test.ts | 4 ++-- e2e/find.test.ts | 4 ++-- e2e/follow.test.ts | 4 ++-- e2e/follow_properties.test.ts | 4 ++-- e2e/jest.config.ts | 13 +++++++++++++ e2e/main.ts | 1 + e2e/mark.test.ts | 4 ++-- e2e/navigate.test.ts | 4 ++-- e2e/options.test.ts | 4 ++-- e2e/partial_blacklist.test.ts | 4 ++-- e2e/repeat.test.ts | 4 ++-- e2e/repeat_n_times.test.ts | 4 ++-- e2e/scroll.test.ts | 4 ++-- e2e/tab.test.ts | 4 ++-- e2e/zoom.test.ts | 4 ++-- package.json | 2 +- 31 files changed, 71 insertions(+), 57 deletions(-) create mode 100644 e2e/jest.config.ts create mode 100644 e2e/main.ts diff --git a/e2e/blacklist.test.ts b/e2e/blacklist.test.ts index db82726..f904a58 100644 --- a/e2e/blacklist.test.ts +++ b/e2e/blacklist.test.ts @@ -17,7 +17,7 @@ describe("blacklist test", () => { let webdriver: WebDriver; let browser: any; - before(async () => { + beforeAll(async () => { lanthan = await Builder.forBrowser("firefox") .spyAddon(path.join(__dirname, "..")) .build(); @@ -36,7 +36,7 @@ describe("blacklist test", () => { ); }); - after(async () => { + afterAll(async () => { await server.stop(); if (lanthan) { await lanthan.quit(); diff --git a/e2e/clipboard.test.ts b/e2e/clipboard.test.ts index 63a20a8..b57eebc 100644 --- a/e2e/clipboard.test.ts +++ b/e2e/clipboard.test.ts @@ -16,7 +16,7 @@ describe("clipboard test", () => { let webdriver: WebDriver; let browser: any; - before(async () => { + beforeAll(async () => { lanthan = await Builder.forBrowser("firefox") .spyAddon(path.join(__dirname, "..")) .build(); @@ -37,7 +37,7 @@ describe("clipboard test", () => { await server.start(); }); - after(async () => { + afterAll(async () => { await server.stop(); if (lanthan) { await lanthan.quit(); diff --git a/e2e/colorscheme.test.ts b/e2e/colorscheme.test.ts index 3927a72..9f77131 100644 --- a/e2e/colorscheme.test.ts +++ b/e2e/colorscheme.test.ts @@ -13,7 +13,7 @@ describe("colorscheme test", () => { let webdriver: WebDriver; let page: Page; - before(async () => { + beforeAll(async () => { const opts = (new FirefoxOptions() as any).setPreference( "ui.systemUsesDarkTheme", 1 @@ -28,7 +28,7 @@ describe("colorscheme test", () => { await server.start(); }); - after(async () => { + afterAll(async () => { await server.stop(); if (lanthan) { await lanthan.quit(); diff --git a/e2e/command_addbookmark.test.ts b/e2e/command_addbookmark.test.ts index 4142e68..176e77f 100644 --- a/e2e/command_addbookmark.test.ts +++ b/e2e/command_addbookmark.test.ts @@ -18,7 +18,7 @@ describe("addbookmark command test", () => { let webdriver: WebDriver; let browser: any; - before(async () => { + beforeAll(async () => { lanthan = await Builder.forBrowser("firefox") .spyAddon(path.join(__dirname, "..")) .build(); @@ -27,7 +27,7 @@ describe("addbookmark command test", () => { await server.start(); }); - after(async () => { + afterAll(async () => { await server.stop(); if (lanthan) { await lanthan.quit(); diff --git a/e2e/command_bdelete.test.ts b/e2e/command_bdelete.test.ts index a85ce50..fff4ccf 100644 --- a/e2e/command_bdelete.test.ts +++ b/e2e/command_bdelete.test.ts @@ -13,7 +13,7 @@ describe("bdelete/bdeletes command test", () => { let webdriver: WebDriver; let browser: any; - before(async () => { + beforeAll(async () => { lanthan = await Builder.forBrowser("firefox") .spyAddon(path.join(__dirname, "..")) .build(); @@ -22,7 +22,7 @@ describe("bdelete/bdeletes command test", () => { await server.start(); }); - after(async () => { + afterAll(async () => { await server.stop(); if (lanthan) { await lanthan.quit(); diff --git a/e2e/command_buffer.test.ts b/e2e/command_buffer.test.ts index 114f4b4..e0aeda3 100644 --- a/e2e/command_buffer.test.ts +++ b/e2e/command_buffer.test.ts @@ -25,7 +25,7 @@ describe("buffer command test", () => { let webdriver: WebDriver; let browser: any; - before(async () => { + beforeAll(async () => { lanthan = await Builder.forBrowser("firefox") .spyAddon(path.join(__dirname, "..")) .build(); @@ -34,7 +34,7 @@ describe("buffer command test", () => { await server.start(); }); - after(async () => { + afterAll(async () => { await server.stop(); if (lanthan) { await lanthan.quit(); diff --git a/e2e/command_help.test.ts b/e2e/command_help.test.ts index 40d4dde..b713317 100644 --- a/e2e/command_help.test.ts +++ b/e2e/command_help.test.ts @@ -14,7 +14,7 @@ describe("help command test", () => { let browser: any; let page: Page; - before(async () => { + beforeAll(async () => { lanthan = await Builder.forBrowser("firefox") .spyAddon(path.join(__dirname, "..")) .build(); @@ -24,7 +24,7 @@ describe("help command test", () => { await server.start(); }); - after(async () => { + afterAll(async () => { await server.stop(); if (lanthan) { await lanthan.quit(); diff --git a/e2e/command_open.test.ts b/e2e/command_open.test.ts index 2db522a..239d775 100644 --- a/e2e/command_open.test.ts +++ b/e2e/command_open.test.ts @@ -18,7 +18,7 @@ describe("open command test", () => { let browser: any; let page: Page; - before(async () => { + beforeAll(async () => { lanthan = await Builder.forBrowser("firefox") .spyAddon(path.join(__dirname, "..")) .build(); @@ -39,7 +39,7 @@ describe("open command test", () => { ); }); - after(async () => { + afterAll(async () => { await server.stop(); if (lanthan) { await lanthan.quit(); diff --git a/e2e/command_quit.test.ts b/e2e/command_quit.test.ts index d59abfc..10706aa 100644 --- a/e2e/command_quit.test.ts +++ b/e2e/command_quit.test.ts @@ -13,7 +13,7 @@ describe("quit/quitall command test", () => { let webdriver: WebDriver; let browser: any; - before(async () => { + beforeAll(async () => { lanthan = await Builder.forBrowser("firefox") .spyAddon(path.join(__dirname, "..")) .build(); @@ -22,7 +22,7 @@ describe("quit/quitall command test", () => { await server.start(); }); - after(async () => { + afterAll(async () => { await server.stop(); if (lanthan) { await lanthan.quit(); diff --git a/e2e/command_tabopen.test.ts b/e2e/command_tabopen.test.ts index 9807a03..0469a5e 100644 --- a/e2e/command_tabopen.test.ts +++ b/e2e/command_tabopen.test.ts @@ -18,7 +18,7 @@ describe("tabopen command test", () => { let browser: any; let page: Page; - before(async () => { + beforeAll(async () => { lanthan = await Builder.forBrowser("firefox") .spyAddon(path.join(__dirname, "..")) .build(); @@ -39,7 +39,7 @@ describe("tabopen command test", () => { ); }); - after(async () => { + afterAll(async () => { await server.stop(); if (lanthan) { await lanthan.quit(); diff --git a/e2e/command_winopen.test.ts b/e2e/command_winopen.test.ts index 1d13edd..829c05f 100644 --- a/e2e/command_winopen.test.ts +++ b/e2e/command_winopen.test.ts @@ -18,7 +18,7 @@ describe("winopen command test", () => { let browser: any; let page: Page; - before(async () => { + beforeAll(async () => { lanthan = await Builder.forBrowser("firefox") .spyAddon(path.join(__dirname, "..")) .build(); @@ -39,7 +39,7 @@ describe("winopen command test", () => { ); }); - after(async () => { + afterAll(async () => { await server.stop(); if (lanthan) { await lanthan.quit(); diff --git a/e2e/completion.test.ts b/e2e/completion.test.ts index c0e7052..258353c 100644 --- a/e2e/completion.test.ts +++ b/e2e/completion.test.ts @@ -11,14 +11,14 @@ describe("general completion test", () => { let webdriver: WebDriver; let page: Page; - before(async () => { + beforeAll(async () => { lanthan = await Builder.forBrowser("firefox") .spyAddon(path.join(__dirname, "..")) .build(); webdriver = lanthan.getWebDriver(); }); - after(async () => { + afterAll(async () => { if (lanthan) { await lanthan.quit(); } diff --git a/e2e/completion_buffers.test.ts b/e2e/completion_buffers.test.ts index 13d07ea..251d4f6 100644 --- a/e2e/completion_buffers.test.ts +++ b/e2e/completion_buffers.test.ts @@ -26,7 +26,7 @@ describe("completion on buffer/bdelete/bdeletes", () => { let browser: any; let page: Page; - before(async () => { + beforeAll(async () => { lanthan = await Builder.forBrowser("firefox") .spyAddon(path.join(__dirname, "..")) .build(); @@ -36,7 +36,7 @@ describe("completion on buffer/bdelete/bdeletes", () => { await server.start(); }); - after(async () => { + afterAll(async () => { await server.stop(); if (lanthan) { await lanthan.quit(); diff --git a/e2e/completion_open.test.ts b/e2e/completion_open.test.ts index 7eef4c2..04cb08c 100644 --- a/e2e/completion_open.test.ts +++ b/e2e/completion_open.test.ts @@ -16,7 +16,7 @@ describe("completion on open/tabopen/winopen commands", () => { let browser: any; let page: Page; - before(async () => { + beforeAll(async () => { await server.start(); lanthan = await Builder.forBrowser("firefox") @@ -29,7 +29,7 @@ describe("completion on open/tabopen/winopen commands", () => { await webdriver.navigate().to("https://example.com/"); }); - after(async () => { + afterAll(async () => { await server.stop(); if (lanthan) { await lanthan.quit(); diff --git a/e2e/completion_set.test.ts b/e2e/completion_set.test.ts index 929f649..e96c4fc 100644 --- a/e2e/completion_set.test.ts +++ b/e2e/completion_set.test.ts @@ -11,14 +11,14 @@ describe("completion on set commands", () => { let webdriver: WebDriver; let page: Page; - before(async () => { + beforeAll(async () => { lanthan = await Builder.forBrowser("firefox") .spyAddon(path.join(__dirname, "..")) .build(); webdriver = lanthan.getWebDriver(); }); - after(async () => { + afterAll(async () => { if (lanthan) { await lanthan.quit(); } diff --git a/e2e/console.test.ts b/e2e/console.test.ts index 18b717f..2b8759a 100644 --- a/e2e/console.test.ts +++ b/e2e/console.test.ts @@ -15,7 +15,7 @@ describe("console test", () => { let webdriver: WebDriver; let page: Page; - before(async () => { + beforeAll(async () => { lanthan = await Builder.forBrowser("firefox") .spyAddon(path.join(__dirname, "..")) .build(); @@ -23,7 +23,7 @@ describe("console test", () => { await server.start(); }); - after(async () => { + afterAll(async () => { await server.stop(); if (lanthan) { await lanthan.quit(); diff --git a/e2e/find.test.ts b/e2e/find.test.ts index dd5069c..729300b 100644 --- a/e2e/find.test.ts +++ b/e2e/find.test.ts @@ -16,7 +16,7 @@ describe("find test", () => { let webdriver: WebDriver; let page: Page; - before(async () => { + beforeAll(async () => { lanthan = await Builder.forBrowser("firefox") .spyAddon(path.join(__dirname, "..")) .build(); @@ -24,7 +24,7 @@ describe("find test", () => { await server.start(); }); - after(async () => { + afterAll(async () => { await server.stop(); if (lanthan) { await lanthan.quit(); diff --git a/e2e/follow.test.ts b/e2e/follow.test.ts index 90f9a59..44d35e4 100644 --- a/e2e/follow.test.ts +++ b/e2e/follow.test.ts @@ -134,7 +134,7 @@ describe("follow test", () => { let webdriver: WebDriver; let browser: any; - before(async () => { + beforeAll(async () => { lanthan = await Builder.forBrowser("firefox") .spyAddon(path.join(__dirname, "..")) .build(); @@ -143,7 +143,7 @@ describe("follow test", () => { await server.start(); }); - after(async () => { + afterAll(async () => { await server.stop(); if (lanthan) { await lanthan.quit(); diff --git a/e2e/follow_properties.test.ts b/e2e/follow_properties.test.ts index 4f2a5b8..4525811 100644 --- a/e2e/follow_properties.test.ts +++ b/e2e/follow_properties.test.ts @@ -28,7 +28,7 @@ describe("follow properties test", () => { let browser: any; let page: Page; - before(async () => { + beforeAll(async () => { lanthan = await Builder.forBrowser("firefox") .spyAddon(path.join(__dirname, "..")) .build(); @@ -52,7 +52,7 @@ describe("follow properties test", () => { await server.start(); }); - after(async () => { + afterAll(async () => { await server.stop(); if (lanthan) { await lanthan.quit(); diff --git a/e2e/jest.config.ts b/e2e/jest.config.ts new file mode 100644 index 0000000..ed197f5 --- /dev/null +++ b/e2e/jest.config.ts @@ -0,0 +1,13 @@ +import type { Config } from "@jest/types"; + +const config: Config.InitialOptions = { + verbose: true, + testMatch: ["**/e2e/**/*.test.+(ts|tsx|js|jsx)"], + transform: { + "^.+\\.(ts|tsx)$": "ts-jest", + }, + setupFiles: ["./main.ts"], + testTimeout: 20000, + maxConcurrency: 1, +}; +export default config; diff --git a/e2e/main.ts b/e2e/main.ts new file mode 100644 index 0000000..359a6b2 --- /dev/null +++ b/e2e/main.ts @@ -0,0 +1 @@ +jest.retryTimes(10); diff --git a/e2e/mark.test.ts b/e2e/mark.test.ts index 0f09d82..b1a48bc 100644 --- a/e2e/mark.test.ts +++ b/e2e/mark.test.ts @@ -16,7 +16,7 @@ describe("mark test", () => { let webdriver: WebDriver; let browser: any; - before(async () => { + beforeAll(async () => { lanthan = await Builder.forBrowser("firefox") .spyAddon(path.join(__dirname, "..")) .build(); @@ -26,7 +26,7 @@ describe("mark test", () => { await server.start(); }); - after(async () => { + afterAll(async () => { await server.stop(); if (lanthan) { await lanthan.quit(); diff --git a/e2e/navigate.test.ts b/e2e/navigate.test.ts index d0942b6..b0f71b3 100644 --- a/e2e/navigate.test.ts +++ b/e2e/navigate.test.ts @@ -56,7 +56,7 @@ describe("navigate test", () => { let webdriver: WebDriver; let browser: any; - before(async () => { + beforeAll(async () => { await server.start(); const opts = (new FirefoxOptions() as any).setPreference( @@ -71,7 +71,7 @@ describe("navigate test", () => { browser = lanthan.getWebExtBrowser(); }); - after(async () => { + afterAll(async () => { await server.stop(); if (lanthan) { await lanthan.quit(); diff --git a/e2e/options.test.ts b/e2e/options.test.ts index 64f24be..c2b44d6 100644 --- a/e2e/options.test.ts +++ b/e2e/options.test.ts @@ -17,7 +17,7 @@ describe("options page", () => { let webdriver: WebDriver; let browser: any; - before(async () => { + beforeAll(async () => { lanthan = await Builder.forBrowser("firefox") .spyAddon(path.join(__dirname, "..")) .build(); @@ -27,7 +27,7 @@ describe("options page", () => { await server.start(); }); - after(async () => { + afterAll(async () => { if (lanthan) { await lanthan.quit(); } diff --git a/e2e/partial_blacklist.test.ts b/e2e/partial_blacklist.test.ts index 8bc1c0e..4959437 100644 --- a/e2e/partial_blacklist.test.ts +++ b/e2e/partial_blacklist.test.ts @@ -17,7 +17,7 @@ describe("partial blacklist test", () => { let webdriver: WebDriver; let browser: any; - before(async () => { + beforeAll(async () => { lanthan = await Builder.forBrowser("firefox") .spyAddon(path.join(__dirname, "..")) .build(); @@ -37,7 +37,7 @@ describe("partial blacklist test", () => { ); }); - after(async () => { + afterAll(async () => { await server.stop(); if (lanthan) { await lanthan.quit(); diff --git a/e2e/repeat.test.ts b/e2e/repeat.test.ts index 04d1331..98ba980 100644 --- a/e2e/repeat.test.ts +++ b/e2e/repeat.test.ts @@ -13,7 +13,7 @@ describe("tab test", () => { let webdriver: WebDriver; let browser: any; - before(async () => { + beforeAll(async () => { lanthan = await Builder.forBrowser("firefox") .spyAddon(path.join(__dirname, "..")) .build(); @@ -22,7 +22,7 @@ describe("tab test", () => { await server.start(); }); - after(async () => { + afterAll(async () => { await server.stop(); if (lanthan) { await lanthan.quit(); diff --git a/e2e/repeat_n_times.test.ts b/e2e/repeat_n_times.test.ts index 5a9b172..207dc37 100644 --- a/e2e/repeat_n_times.test.ts +++ b/e2e/repeat_n_times.test.ts @@ -16,7 +16,7 @@ describe("tab test", () => { let webdriver: WebDriver; let browser: any; - before(async () => { + beforeAll(async () => { lanthan = await Builder.forBrowser("firefox") .spyAddon(path.join(__dirname, "..")) .build(); @@ -25,7 +25,7 @@ describe("tab test", () => { await server.start(); }); - after(async () => { + afterAll(async () => { await server.stop(); if (lanthan) { await lanthan.quit(); diff --git a/e2e/scroll.test.ts b/e2e/scroll.test.ts index 277bb2e..da31a3e 100644 --- a/e2e/scroll.test.ts +++ b/e2e/scroll.test.ts @@ -15,7 +15,7 @@ describe("scroll test", () => { let webdriver: WebDriver; let page: Page; - before(async () => { + beforeAll(async () => { lanthan = await Builder.forBrowser("firefox") .spyAddon(path.join(__dirname, "..")) .build(); @@ -23,7 +23,7 @@ describe("scroll test", () => { await server.start(); }); - after(async () => { + afterAll(async () => { await server.stop(); if (lanthan) { await lanthan.quit(); diff --git a/e2e/tab.test.ts b/e2e/tab.test.ts index b59c246..b2767b2 100644 --- a/e2e/tab.test.ts +++ b/e2e/tab.test.ts @@ -15,7 +15,7 @@ describe("tab test", () => { let win: any; let tabs: any[]; - before(async () => { + beforeAll(async () => { lanthan = await Builder.forBrowser("firefox") .spyAddon(path.join(__dirname, "..")) .build(); @@ -24,7 +24,7 @@ describe("tab test", () => { await server.start(); }); - after(async () => { + afterAll(async () => { await server.stop(); if (lanthan) { await lanthan.quit(); diff --git a/e2e/zoom.test.ts b/e2e/zoom.test.ts index 5e21774..fcdd509 100644 --- a/e2e/zoom.test.ts +++ b/e2e/zoom.test.ts @@ -13,7 +13,7 @@ describe("zoom test", () => { let tab: any; let page: Page; - before(async () => { + beforeAll(async () => { lanthan = await Builder.forBrowser("firefox") .spyAddon(path.join(__dirname, "..")) .build(); @@ -23,7 +23,7 @@ describe("zoom test", () => { page = await Page.currentContext(webdriver); }); - after(async () => { + afterAll(async () => { await lanthan.quit(); }); diff --git a/package.json b/package.json index a44978d..458bfa9 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "lint:fix": "eslint --ext .ts,.tsx . --fix", "type-checks": "tsc --noEmit", "test": "jest", - "test:e2e": "mocha --timeout 20000 --retries 10 --require ts-node/register --extension ts e2e" + "test:e2e": "jest --config e2e/jest.config.ts e2e" }, "repository": { "type": "git", -- cgit v1.2.3