From 1b92be636008e9211f460479e246331ba4a1f8f1 Mon Sep 17 00:00:00 2001 From: Shin'ya UEOKA Date: Fri, 27 Sep 2019 10:02:12 +0000 Subject: Use TestServer on e2e --- e2e/options.test.ts | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) (limited to 'e2e/options.test.ts') 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(` - - -`); - }); - return app; -}; - describe("options page", () => { - const port = 12321; - let http: http.Server; + let server = new TestServer().receiveContent('/', + ``, + ); 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]); -- cgit v1.2.3