diff options
author | Shin'ya UEOKA <ueokande@i-beam.org> | 2019-09-27 10:02:12 +0000 |
---|---|---|
committer | Shin'ya UEOKA <ueokande@i-beam.org> | 2019-09-29 00:13:04 +0000 |
commit | 1b92be636008e9211f460479e246331ba4a1f8f1 (patch) | |
tree | 8dbba51444f5f52ad91f0357d2d7035298394452 /e2e/command_quit.test.ts | |
parent | 4a4b5e13031898440421cef7230c2742e6cd226a (diff) |
Use TestServer on e2e
Diffstat (limited to 'e2e/command_quit.test.ts')
-rw-r--r-- | e2e/command_quit.test.ts | 28 |
1 files changed, 6 insertions, 22 deletions
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(`<!DOCTYPEhtml> -<html lang="en"> - <head> - <title>my_${req.path.slice(1)}</title> - </head> - <body><h1>${req.path}</h1></body> -</html">`); - }); - 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() => { |