Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add in some functional tests, using Lerna to manage the dependencies …
…of each test 'repo'
- Loading branch information
1 parent
1818c22
commit 7ecb8b8
Showing
25 changed files
with
35,521 additions
and
2,718 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
node_modules | ||
lerna-debug.log |
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,3 @@ | ||
examples/ | ||
.prettierrc | ||
__tests__/ |
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,4 @@ | ||
require("./constants"); | ||
require("./styles.css"); | ||
|
||
console.log("Some javascript", FOO); |
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 @@ | ||
const a = 1; |
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,70 @@ | ||
const SpeedMeasurePlugin = require("../../.."); | ||
const webpack = require("webpack"); | ||
const { readFileSync } = require("fs"); | ||
const webpackConfig = require("./webpack.config"); | ||
|
||
const genSmpWebpackConfig = smp => | ||
smp.wrap( | ||
Object.assign({}, webpackConfig, { | ||
output: { | ||
path: webpackConfig.output.path + "/_smp_" + new Date().getTime(), | ||
}, | ||
}) | ||
); | ||
|
||
const runWebpack = config => | ||
new Promise((resolve, reject) => { | ||
webpack(config, (err, stats) => { | ||
if (err || stats.hasErrors()) return reject(err || stats); | ||
resolve(readFileSync(config.output.path + "/bundle.js").toString()); | ||
}); | ||
}); | ||
|
||
describe("smp - " + __dirname.split("/").pop(), () => { | ||
let distApp; | ||
beforeAll(() => runWebpack(webpackConfig).then(file => (distApp = file))); | ||
|
||
describe("vanilla config", () => { | ||
let smpOutput; | ||
let smpDistApp; | ||
const smp = new SpeedMeasurePlugin({ | ||
outputTarget: output => (smpOutput = output), | ||
}); | ||
const smpWebpackConfig = genSmpWebpackConfig(smp); | ||
|
||
beforeAll(() => | ||
runWebpack(smpWebpackConfig).then(file => (smpDistApp = file)) | ||
); | ||
|
||
it("should generate the same app.js content", () => { | ||
expect(smpDistApp).toEqual(distApp); | ||
}); | ||
|
||
it("should generate the same app.js content after 2 runs", () => { | ||
const dupSmpWebpackConfig = genSmpWebpackConfig(smp); | ||
|
||
return runWebpack(dupSmpWebpackConfig).then(dupSmpDistApp => { | ||
expect(dupSmpDistApp).toEqual(smpDistApp); | ||
expect(dupSmpDistApp).toEqual(distApp); | ||
}); | ||
}); | ||
|
||
it("should state the time taken overall", () => { | ||
expect(smpOutput).toMatch( | ||
/General output time took .*([0-9]+ mins? )?[0-9]+(\.[0-9]+)? secs/ | ||
); | ||
}); | ||
|
||
it("should state the time taken by the plugins", () => { | ||
expect(smpOutput).toMatch( | ||
/DefinePlugin.* took .*([0-9]+ mins? )?[0-9]+(\.[0-9]+)? secs/ | ||
); | ||
}); | ||
|
||
it("should state the time taken by the loaders", () => { | ||
expect(smpOutput).toMatch( | ||
/babel-loader.* took .*([0-9]+ mins? )?[0-9]+(\.[0-9]+)? secs.*\n\s+module count\s+= [0-9]+/ | ||
); | ||
}); | ||
}); | ||
}); |
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,3 @@ | ||
.a { | ||
color: red; | ||
} |
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,5 @@ | ||
app.js | ||
constants.js | ||
styles.css | ||
smp.test.js | ||
dist |
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,3 @@ | ||
{ | ||
"trailingComma": "es5" | ||
} |
Oops, something went wrong.