-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a57d1fd
commit 91f5110
Showing
4 changed files
with
242 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`app option should work using "connect (async)" application and "/home/akait/IdeaProjects/webpack-dev-server/test/helpers/custom-http.js" server should handle GET request to index route (/): console messages 1`] = `[]`; | ||
|
||
exports[`app option should work using "connect (async)" application and "/home/akait/IdeaProjects/webpack-dev-server/test/helpers/custom-http.js" server should handle GET request to index route (/): page errors 1`] = `[]`; | ||
|
||
exports[`app option should work using "connect (async)" application and "/home/akait/IdeaProjects/webpack-dev-server/test/helpers/custom-http.js" server should handle GET request to index route (/): response status 1`] = `200`; | ||
|
||
exports[`app option should work using "connect (async)" application and "/home/akait/IdeaProjects/webpack-dev-server/test/helpers/custom-http.js" server should handle GET request to index route (/): response text 1`] = ` | ||
"Heyo. | ||
" | ||
`; | ||
|
||
exports[`app option should work using "connect (async)" application and "http" server should handle GET request to index route (/): console messages 1`] = `[]`; | ||
|
||
exports[`app option should work using "connect (async)" application and "http" server should handle GET request to index route (/): page errors 1`] = `[]`; | ||
|
||
exports[`app option should work using "connect (async)" application and "http" server should handle GET request to index route (/): response status 1`] = `200`; | ||
|
||
exports[`app option should work using "connect (async)" application and "http" server should handle GET request to index route (/): response text 1`] = ` | ||
"Heyo. | ||
" | ||
`; | ||
|
||
exports[`app option should work using "connect (async)" application and "https" server should handle GET request to index route (/): console messages 1`] = `[]`; | ||
|
||
exports[`app option should work using "connect (async)" application and "https" server should handle GET request to index route (/): page errors 1`] = `[]`; | ||
|
||
exports[`app option should work using "connect (async)" application and "https" server should handle GET request to index route (/): response status 1`] = `200`; | ||
|
||
exports[`app option should work using "connect (async)" application and "https" server should handle GET request to index route (/): response text 1`] = ` | ||
"Heyo. | ||
" | ||
`; | ||
|
||
exports[`app option should work using "connect (async)" application and "spdy" server should handle GET request to index route (/): console messages 1`] = `[]`; | ||
|
||
exports[`app option should work using "connect (async)" application and "spdy" server should handle GET request to index route (/): page errors 1`] = `[]`; | ||
|
||
exports[`app option should work using "connect (async)" application and "spdy" server should handle GET request to index route (/): response status 1`] = `200`; | ||
|
||
exports[`app option should work using "connect (async)" application and "spdy" server should handle GET request to index route (/): response text 1`] = ` | ||
"Heyo. | ||
" | ||
`; | ||
|
||
exports[`app option should work using "connect" application and "/home/akait/IdeaProjects/webpack-dev-server/test/helpers/custom-http.js" server should handle GET request to index route (/): console messages 1`] = `[]`; | ||
|
||
exports[`app option should work using "connect" application and "/home/akait/IdeaProjects/webpack-dev-server/test/helpers/custom-http.js" server should handle GET request to index route (/): page errors 1`] = `[]`; | ||
|
||
exports[`app option should work using "connect" application and "/home/akait/IdeaProjects/webpack-dev-server/test/helpers/custom-http.js" server should handle GET request to index route (/): response status 1`] = `200`; | ||
|
||
exports[`app option should work using "connect" application and "/home/akait/IdeaProjects/webpack-dev-server/test/helpers/custom-http.js" server should handle GET request to index route (/): response text 1`] = ` | ||
"Heyo. | ||
" | ||
`; | ||
|
||
exports[`app option should work using "connect" application and "http" server should handle GET request to index route (/): console messages 1`] = `[]`; | ||
|
||
exports[`app option should work using "connect" application and "http" server should handle GET request to index route (/): page errors 1`] = `[]`; | ||
|
||
exports[`app option should work using "connect" application and "http" server should handle GET request to index route (/): response status 1`] = `200`; | ||
|
||
exports[`app option should work using "connect" application and "http" server should handle GET request to index route (/): response text 1`] = ` | ||
"Heyo. | ||
" | ||
`; | ||
|
||
exports[`app option should work using "connect" application and "https" server should handle GET request to index route (/): console messages 1`] = `[]`; | ||
|
||
exports[`app option should work using "connect" application and "https" server should handle GET request to index route (/): page errors 1`] = `[]`; | ||
|
||
exports[`app option should work using "connect" application and "https" server should handle GET request to index route (/): response status 1`] = `200`; | ||
|
||
exports[`app option should work using "connect" application and "https" server should handle GET request to index route (/): response text 1`] = ` | ||
"Heyo. | ||
" | ||
`; | ||
|
||
exports[`app option should work using "connect" application and "spdy" server should handle GET request to index route (/): console messages 1`] = `[]`; | ||
|
||
exports[`app option should work using "connect" application and "spdy" server should handle GET request to index route (/): page errors 1`] = `[]`; | ||
|
||
exports[`app option should work using "connect" application and "spdy" server should handle GET request to index route (/): response status 1`] = `200`; | ||
|
||
exports[`app option should work using "connect" application and "spdy" server should handle GET request to index route (/): response text 1`] = ` | ||
"Heyo. | ||
" | ||
`; | ||
|
||
exports[`app option should work using "express" application and "/home/akait/IdeaProjects/webpack-dev-server/test/helpers/custom-http.js" server should handle GET request to index route (/): console messages 1`] = `[]`; | ||
|
||
exports[`app option should work using "express" application and "/home/akait/IdeaProjects/webpack-dev-server/test/helpers/custom-http.js" server should handle GET request to index route (/): page errors 1`] = `[]`; | ||
|
||
exports[`app option should work using "express" application and "/home/akait/IdeaProjects/webpack-dev-server/test/helpers/custom-http.js" server should handle GET request to index route (/): response status 1`] = `200`; | ||
|
||
exports[`app option should work using "express" application and "/home/akait/IdeaProjects/webpack-dev-server/test/helpers/custom-http.js" server should handle GET request to index route (/): response text 1`] = ` | ||
"Heyo. | ||
" | ||
`; | ||
|
||
exports[`app option should work using "express" application and "http" server should handle GET request to index route (/): console messages 1`] = `[]`; | ||
|
||
exports[`app option should work using "express" application and "http" server should handle GET request to index route (/): page errors 1`] = `[]`; | ||
|
||
exports[`app option should work using "express" application and "http" server should handle GET request to index route (/): response status 1`] = `200`; | ||
|
||
exports[`app option should work using "express" application and "http" server should handle GET request to index route (/): response text 1`] = ` | ||
"Heyo. | ||
" | ||
`; | ||
|
||
exports[`app option should work using "express" application and "https" server should handle GET request to index route (/): console messages 1`] = `[]`; | ||
|
||
exports[`app option should work using "express" application and "https" server should handle GET request to index route (/): page errors 1`] = `[]`; | ||
|
||
exports[`app option should work using "express" application and "https" server should handle GET request to index route (/): response status 1`] = `200`; | ||
|
||
exports[`app option should work using "express" application and "https" server should handle GET request to index route (/): response text 1`] = ` | ||
"Heyo. | ||
" | ||
`; | ||
|
||
exports[`app option should work using "express" application and "spdy" server should handle GET request to index route (/): console messages 1`] = `[]`; | ||
|
||
exports[`app option should work using "express" application and "spdy" server should handle GET request to index route (/): page errors 1`] = `[]`; | ||
|
||
exports[`app option should work using "express" application and "spdy" server should handle GET request to index route (/): response status 1`] = `200`; | ||
|
||
exports[`app option should work using "express" application and "spdy" server should handle GET request to index route (/): response text 1`] = ` | ||
"Heyo. | ||
" | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
"use strict"; | ||
|
||
const path = require("path"); | ||
const webpack = require("webpack"); | ||
const Server = require("../../lib/Server"); | ||
const config = require("../fixtures/static-config/webpack.config"); | ||
const runBrowser = require("../helpers/run-browser"); | ||
const port = require("../ports-map").app; | ||
|
||
const staticDirectory = path.resolve( | ||
__dirname, | ||
"../fixtures/static-config/public", | ||
); | ||
|
||
const apps = [ | ||
["express", () => require("express")()], | ||
["connect", () => require("connect")()], | ||
["connect (async)", async () => require("express")()], | ||
]; | ||
|
||
const servers = [ | ||
"http", | ||
"https", | ||
path.resolve(__dirname, "../helpers/custom-http.js"), | ||
"spdy", | ||
]; | ||
|
||
describe("app option", () => { | ||
for (const [appName, app] of apps) { | ||
for (const server of servers) { | ||
let compiler; | ||
let devServer; | ||
let page; | ||
let browser; | ||
let pageErrors; | ||
let consoleMessages; | ||
|
||
describe(`should work using "${appName}" application and "${server}" server`, () => { | ||
beforeEach(async () => { | ||
compiler = webpack(config); | ||
|
||
devServer = new Server( | ||
{ | ||
static: { | ||
directory: staticDirectory, | ||
watch: false, | ||
}, | ||
app, | ||
server, | ||
port, | ||
}, | ||
compiler, | ||
); | ||
|
||
await devServer.start(); | ||
|
||
({ page, browser } = await runBrowser()); | ||
|
||
pageErrors = []; | ||
consoleMessages = []; | ||
}); | ||
|
||
afterEach(async () => { | ||
await browser.close(); | ||
await devServer.stop(); | ||
}); | ||
|
||
it("should handle GET request to index route (/)", async () => { | ||
page | ||
.on("console", (message) => { | ||
consoleMessages.push(message); | ||
}) | ||
.on("pageerror", (error) => { | ||
pageErrors.push(error); | ||
}); | ||
|
||
const pageUrl = | ||
server === "https" || server === "spdy" || server === "http2" | ||
? `https://127.0.0.1:${port}/` | ||
: `http://127.0.0.1:${port}/`; | ||
|
||
const response = await page.goto(pageUrl, { | ||
waitUntil: "networkidle0", | ||
}); | ||
|
||
const HTTPVersion = await page.evaluate( | ||
() => performance.getEntries()[0].nextHopProtocol, | ||
); | ||
|
||
const isSpdy = server === "spdy"; | ||
|
||
if (isSpdy) { | ||
expect(HTTPVersion).toEqual("h2"); | ||
} else { | ||
expect(HTTPVersion).toEqual("http/1.1"); | ||
} | ||
|
||
expect(response.status()).toMatchSnapshot("response status"); | ||
expect(await response.text()).toMatchSnapshot("response text"); | ||
expect( | ||
consoleMessages.map((message) => message.text()), | ||
).toMatchSnapshot("console messages"); | ||
expect(pageErrors).toMatchSnapshot("page errors"); | ||
}); | ||
}); | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters