fix(tests): simplify tests
This commit is contained in:
@ -5,24 +5,27 @@ const base = require("./webpack.base.config");
|
||||
// Test files are scattered through the whole project. Here we're searching
|
||||
// for them and generating entry file for webpack.
|
||||
|
||||
const e2eDir = jetpack.cwd("tests");
|
||||
const testsDir = jetpack.cwd("tests");
|
||||
const tempDir = jetpack.cwd("temp");
|
||||
const entryFilePath = tempDir.path("e2e_entry.js");
|
||||
const entryFilePath = tempDir.path("testsInit.js");
|
||||
|
||||
const entryFileContent = e2eDir
|
||||
const testsImports = testsDir
|
||||
.find({ matching: "*.test.js" })
|
||||
.reduce((fileContent, path) => {
|
||||
const normalizedPath = path.replace(/\\/g, "/");
|
||||
return `${fileContent}import "../tests/${normalizedPath}";\n`;
|
||||
return `${fileContent}require("../tests/${normalizedPath}");\n`;
|
||||
}, "");
|
||||
|
||||
let entryFileContent = testsDir.read('init.js')
|
||||
entryFileContent = entryFileContent.replace('//TESTS', testsImports)
|
||||
|
||||
jetpack.write(entryFilePath, entryFileContent);
|
||||
|
||||
module.exports = env => {
|
||||
return merge(base(env), {
|
||||
entry: entryFilePath,
|
||||
output: {
|
||||
filename: "e2e.js",
|
||||
filename: "tests.js",
|
||||
path: tempDir.path()
|
||||
}
|
||||
});
|
@ -1,29 +0,0 @@
|
||||
const merge = require("webpack-merge");
|
||||
const jetpack = require("fs-jetpack");
|
||||
const base = require("./webpack.base.config");
|
||||
|
||||
// Test files are scattered through the whole project. Here we're searching
|
||||
// for them and generating entry file for webpack.
|
||||
|
||||
const srcDir = jetpack.cwd("src");
|
||||
const tempDir = jetpack.cwd("temp");
|
||||
const entryFilePath = tempDir.path("specs_entry.js");
|
||||
|
||||
const entryFileContent = srcDir
|
||||
.find({ matching: "*.spec.js" })
|
||||
.reduce((fileContent, path) => {
|
||||
const normalizedPath = path.replace(/\\/g, "/");
|
||||
return `${fileContent}import "../src/${normalizedPath}";\n`;
|
||||
}, "");
|
||||
|
||||
jetpack.write(entryFilePath, entryFileContent);
|
||||
|
||||
module.exports = env => {
|
||||
return merge(base(env), {
|
||||
entry: entryFilePath,
|
||||
output: {
|
||||
filename: "specs.js",
|
||||
path: tempDir.path()
|
||||
}
|
||||
});
|
||||
};
|
Reference in New Issue
Block a user