aboutsummaryrefslogtreecommitdiff
path: root/e2e/options.test.ts
diff options
context:
space:
mode:
authorShin'ya UEOKA <ueokande@i-beam.org>2019-09-27 10:02:12 +0000
committerShin'ya UEOKA <ueokande@i-beam.org>2019-09-29 00:13:04 +0000
commit1b92be636008e9211f460479e246331ba4a1f8f1 (patch)
tree8dbba51444f5f52ad91f0357d2d7035298394452 /e2e/options.test.ts
parent4a4b5e13031898440421cef7230c2742e6cd226a (diff)
Use TestServer on e2e
Diffstat (limited to 'e2e/options.test.ts')
-rw-r--r--e2e/options.test.ts31
1 files changed, 9 insertions, 22 deletions
diff --git a/e2e/options.test.ts b/e2e/options.test.ts
index 6f05ab0..7cf1ecd 100644
--- a/e2e/options.test.ts
+++ b/e2e/options.test.ts
@@ -1,50 +1,37 @@
-import express from 'express';
import * as path from 'path';
import * as assert from 'assert';
-import * as http from 'http';
-import eventually from './eventually';
+import TestServer from './lib/TestServer';
+import eventually from './eventually';
import { Builder, Lanthan } from 'lanthan';
import { WebDriver } from 'selenium-webdriver';
import Page from './lib/Page';
import OptionPage from './lib/OptionPage';
-const newApp = () => {
- let app = express();
- app.get('/', (_req, res) => {
- res.send(`<!DOCTYPEhtml>
-<html lang="en">
- <body style="width:10000px; height:10000px"></body>
-</html">`);
- });
- return app;
-};
-
describe("options page", () => {
- const port = 12321;
- let http: http.Server;
+ let server = new TestServer().receiveContent('/',
+ `<!DOCTYPE html><html lang="en"><body style="width:10000px; height:10000px"></body></html">`,
+ );
let lanthan: Lanthan;
let webdriver: WebDriver;
let browser: any;
before(async() => {
- http = newApp().listen(port);
-
lanthan = await Builder
.forBrowser('firefox')
.spyAddon(path.join(__dirname, '..'))
.build();
webdriver = lanthan.getWebDriver();
browser = lanthan.getWebExtBrowser();
+
+ await server.start();
});
after(async() => {
if (lanthan) {
await lanthan.quit();
}
- if (http) {
- http.close();
- }
+ await server.stop();
});
beforeEach(async() => {
@@ -78,7 +65,7 @@ describe("options page", () => {
let jsonPage = await optionPage.asJSONOptionPage();
await jsonPage.updateSettings(`{ "keymaps": { "zz": { "type": "scroll.vertically", "count": 10 } } }`);
- await browser.tabs.create({ url: `http://127.0.0.1:${port}`, active: false });
+ await browser.tabs.create({ url: server.url(), active: false });
await new Promise((resolve) => setTimeout(resolve, 100));
let handles = await webdriver.getAllWindowHandles();
await webdriver.switchTo().window(handles[1]);