Skip to content

Commit af655ba

Browse files
committed
test: Two tests for checking "Error handling functionality" were added
1 parent 686bb44 commit af655ba

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

mocha/e2e.spec.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const _404PageUrl = `http://127.0.0.1:${PORT2}/404`
1919

2020
const staticServer = new StaticServer(PORT, __dirname)
2121
const staticServer2 = new StaticServer(PORT2)
22+
const staticServerErr = new StaticServer(PORT)
2223

2324
before(async () => {
2425
global.expect = expect
@@ -40,6 +41,22 @@ before(async () => {
4041
await Promise.all([staticServer.listen(), staticServer2.listen(), launchPuppeteerPromise])
4142
})
4243

44+
describe('Error handling functionality', () => {
45+
it("Multiple `listen()` invocation", (done) => {
46+
staticServer.listen().then(() => expect(true).to.be.false, err => {
47+
expect(err.toString()).to.include('ERR_SERVER_ALREADY_LISTEN')
48+
done()
49+
})
50+
})
51+
52+
it("Listen to a busy port", (done) => {
53+
staticServerErr.listen().then(() => expect(true).to.be.false, err => {
54+
expect(err.toString()).to.include(`EADDRINUSE`)
55+
done()
56+
})
57+
})
58+
})
59+
4360
describe('End-to-end tests using puppeteer', () => {
4461
it('Should load mock page as expected and without any error', async () => {
4562
const page = (await browser.pages())[0];
@@ -56,7 +73,7 @@ describe('End-to-end tests using puppeteer', () => {
5673
expect(response.status()).to.equal(200)
5774

5875
expect(response.headers()['content-type']).to.equal('text/html')
59-
76+
6077
expect(await page.title()).to.equal('Mock HTML')
6178

6279
expect(await page.evaluate(() => [

0 commit comments

Comments
 (0)