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/command_quit.test.ts | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) (limited to 'e2e/command_quit.test.ts') diff --git a/e2e/command_quit.test.ts b/e2e/command_quit.test.ts index 29de86a..d187ccb 100644 --- a/e2e/command_quit.test.ts +++ b/e2e/command_quit.test.ts @@ -1,46 +1,30 @@ -import express from 'express'; import * as path from 'path'; import * as assert from 'assert'; -import * as http from 'http'; +import TestServer from './lib/TestServer'; import eventually from './eventually'; import { Builder, Lanthan } from 'lanthan'; import { WebDriver } from 'selenium-webdriver'; import Page from './lib/Page'; -const newApp = () => { - let app = express(); - app.get('/*', (req, res) => { - res.send(` - - - my_${req.path.slice(1)} - -

${req.path}

-`); - }); - return app; -}; - describe('quit/quitall command test', () => { - const port = 12321; - let http: http.Server; + let server = new TestServer().receiveContent('/*', 'ok'); 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() => { - http.close(); + await server.stop(); if (lanthan) { await lanthan.quit(); } @@ -51,9 +35,9 @@ describe('quit/quitall command test', () => { for (let tab of tabs.slice(1)) { await browser.tabs.remove(tab.id); } - await browser.tabs.update(tabs[0].id, { url: `http://127.0.0.1:${port}/site1` }); + await browser.tabs.update(tabs[0].id, { url: server.url('/site1') }); for (let i = 2; i <= 5; ++i) { - await browser.tabs.create({ url: `http://127.0.0.1:${port}/site${i}`}) + await browser.tabs.create({ url: server.url('/site' + i) }) } await eventually(async() => { -- cgit v1.2.3