mirror of https://github.com/webpack/webpack.git
fix a few more expects and make the test output paths more sturdy
This commit is contained in:
parent
b2c54f176e
commit
e7a671fe65
|
@ -11,12 +11,12 @@ describe("Examples", () => {
|
|||
|
||||
examples.forEach((examplePath) => {
|
||||
const filterPath = path.join(examplePath, "test.filter.js");
|
||||
const relativePath = path.relative(basePath, examplePath);
|
||||
if(fs.existsSync(filterPath) && !require(filterPath)()) {
|
||||
describe.skip(path.relative(basePath, examplePath), () => it("filtered"));
|
||||
describe.skip(relativePath, () => it("filtered"));
|
||||
return;
|
||||
}
|
||||
it("should compile " + path.relative(basePath, examplePath), function(done) {
|
||||
jest.setTimeout(20000);
|
||||
it("should compile " + relativePath, function(done) {
|
||||
let options = {};
|
||||
let webpackConfigPath = path.join(examplePath, "webpack.config.js");
|
||||
webpackConfigPath = webpackConfigPath.substr(0, 1).toUpperCase() + webpackConfigPath.substr(1);
|
||||
|
@ -53,6 +53,6 @@ describe("Examples", () => {
|
|||
}
|
||||
done();
|
||||
});
|
||||
});
|
||||
}, 20000);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -2,18 +2,19 @@
|
|||
|
||||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
const mkdirp = require("mkdirp");
|
||||
|
||||
const webpack = require("../");
|
||||
|
||||
describe("HotModuleReplacementPlugin", () => {
|
||||
jest.setTimeout(10000);
|
||||
it("should not have circular hashes but equal if unmodified", (done) => {
|
||||
const entryFile = path.join(__dirname, "js", "entry.js");
|
||||
const statsFile1 = path.join(__dirname, "js", "HotModuleReplacementPlugin.test.stats1.txt");
|
||||
const statsFile2 = path.join(__dirname, "js", "HotModuleReplacementPlugin.test.stats2.txt");
|
||||
const recordsFile = path.join(__dirname, "js", "records.json");
|
||||
const entryFile = path.join(__dirname, "js", "HotModuleReplacementPlugin", "entry.js");
|
||||
const statsFile1 = path.join(__dirname, "js", "HotModuleReplacementPlugin", "HotModuleReplacementPlugin.test.stats1.txt");
|
||||
const statsFile2 = path.join(__dirname, "js", "HotModuleReplacementPlugin", "HotModuleReplacementPlugin.test.stats2.txt");
|
||||
const recordsFile = path.join(__dirname, "js", "HotModuleReplacementPlugin", "records.json");
|
||||
try {
|
||||
fs.mkdirSync(path.join(__dirname, "js"));
|
||||
mkdirp.sync(path.join(__dirname, "js", "HotModuleReplacementPlugin"));
|
||||
} catch(e) {}
|
||||
try {
|
||||
fs.unlinkSync(recordsFile);
|
||||
|
@ -23,7 +24,7 @@ describe("HotModuleReplacementPlugin", () => {
|
|||
entry: entryFile,
|
||||
recordsPath: recordsFile,
|
||||
output: {
|
||||
path: path.join(__dirname, "js")
|
||||
path: path.join(__dirname, "js", "HotModuleReplacementPlugin")
|
||||
},
|
||||
plugins: [
|
||||
new webpack.HotModuleReplacementPlugin(),
|
||||
|
|
|
@ -12,7 +12,7 @@ describe("NodeTemplatePlugin", () => {
|
|||
context: path.join(__dirname, "fixtures", "nodetest"),
|
||||
target: "node",
|
||||
output: {
|
||||
path: path.join(__dirname, "js"),
|
||||
path: path.join(__dirname, "js", "NodeTemplatePlugin"),
|
||||
filename: "result.js",
|
||||
chunkFilename: "[hash].result.[id].js",
|
||||
library: "abc",
|
||||
|
@ -24,7 +24,7 @@ describe("NodeTemplatePlugin", () => {
|
|||
expect(stats.hasErrors()).toBe(false);
|
||||
expect(stats.hasWarnings()).toBe(false);
|
||||
// eslint-disable-next-line node/no-missing-require
|
||||
const result = require("./js/result").abc;
|
||||
const result = require("./js/NodeTemplatePlugin/result").abc;
|
||||
expect(result.nextTick).toBe(process.nextTick);
|
||||
expect(result.fs).toBe(require("fs"));
|
||||
result.loadChunk(456, (chunk) => {
|
||||
|
@ -45,7 +45,7 @@ describe("NodeTemplatePlugin", () => {
|
|||
context: path.join(__dirname, "fixtures", "nodetest"),
|
||||
target: "node",
|
||||
output: {
|
||||
path: path.join(__dirname, "js"),
|
||||
path: path.join(__dirname, "js", "NodeTemplatePluginSingle"),
|
||||
filename: "result2.js",
|
||||
chunkFilename: "[hash].result2.[id].js",
|
||||
library: "def",
|
||||
|
@ -62,7 +62,7 @@ describe("NodeTemplatePlugin", () => {
|
|||
if(err) return err;
|
||||
expect(stats.hasErrors()).toBe(false);
|
||||
// eslint-disable-next-line node/no-missing-require
|
||||
const result = require("./js/result2");
|
||||
const result = require("./js/NodeTemplatePluginSingle/result2");
|
||||
expect(result.nextTick).toBe(process.nextTick);
|
||||
expect(result.fs).toBe(require("fs"));
|
||||
const sameTick = true;
|
||||
|
|
|
@ -6,7 +6,7 @@ import e from "../data/e.json";
|
|||
import f from "../data/f.json";
|
||||
|
||||
it("should be possible to import json data", function() {
|
||||
({a}expect()).toEqual({a: null});
|
||||
expect({a}).toEqual({a: null});
|
||||
expect(b).toBe(123);
|
||||
expect(c).toEqual([1, 2, 3, 4]);
|
||||
expect(d).toEqual({});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
it("should handle the jade loader correctly", function() {
|
||||
require("!jade-loader?self!../_resources/template.jade")({abc: "abc"}expect()).toBe("<p>selfabc</p><h1>included</h1>");
|
||||
require("../_resources/template.jade")({abc: "abc"}expect()).toBe("<p>abc</p><h1>included</h1>");
|
||||
expect(require("!jade-loader?self!../_resources/template.jade")({ abc: "abc" })).toBe("<p>selfabc</p><h1>included</h1>");
|
||||
expect(require("../_resources/template.jade")({ abc: "abc" })).toBe("<p>abc</p><h1>included</h1>");
|
||||
});
|
||||
|
|
|
@ -5,13 +5,13 @@ import { ns, default as def1, def as def2, data as data2 } from "./reexport.mjs"
|
|||
import * as reexport from "./reexport.mjs";
|
||||
|
||||
it("should get correct values when importing named exports from a CommonJs module from mjs", function() {
|
||||
expect((typeof data)).toBe("undefined");
|
||||
({ data }expect()).toEqual({ data: undefined });
|
||||
expect(typeof data).toBe("undefined");
|
||||
expect({ data }).toEqual({ data: undefined });
|
||||
expect(def).toEqual({
|
||||
data: "ok",
|
||||
default: "default"
|
||||
});
|
||||
({ def }expect()).toEqual({
|
||||
expect({ def }).toEqual({
|
||||
def: {
|
||||
data: "ok",
|
||||
default: "default"
|
||||
|
@ -24,7 +24,7 @@ it("should get correct values when importing named exports from a CommonJs modul
|
|||
default: "default"
|
||||
}
|
||||
});
|
||||
({ star }expect()).toEqual({
|
||||
expect({ star }).toEqual({
|
||||
star: {
|
||||
default: {
|
||||
data: "ok",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import {x, f} from "./x";
|
||||
|
||||
it("should import into object literal", function() {
|
||||
({ x: x }expect()).toEqual({x: 1});
|
||||
(expect({ x: x })).toEqual({x: 1});
|
||||
var obj = { x: x };
|
||||
expect(obj).toEqual({x: 1});
|
||||
});
|
||||
|
@ -13,8 +13,8 @@ function func(z) {
|
|||
it("should import into function argument", function() {
|
||||
expect(func(x)).toBe(1);
|
||||
expect(f(x)).toBe(1);
|
||||
func({x:x}expect()).toEqual({x:1});
|
||||
f({x:x}expect()).toEqual({x:1});
|
||||
expect(func({x:x})).toEqual({x:1});
|
||||
expect(f({x:x})).toEqual({x:1});
|
||||
var y = f(x);
|
||||
expect(y).toBe(1);
|
||||
y = function() {
|
||||
|
@ -24,8 +24,8 @@ it("should import into function argument", function() {
|
|||
});
|
||||
|
||||
it("should import into array literal", function() {
|
||||
expect(([x, f(2)])).toEqual([1, 2]);
|
||||
([{
|
||||
expect([x, f(2)]).toEqual([1, 2]);
|
||||
expect([{
|
||||
value: x
|
||||
}expect(])).toEqual([{ value: x }]);
|
||||
}]).toEqual([{ value: x }]);
|
||||
});
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
function testCase(number) {
|
||||
expect(require(number === 1 ? "./folder/file1" : number === 2 ? "./folder/file2" : number === 3 ? "./folder/file3" : "./missingModule")).toBe("file" + number);
|
||||
require(
|
||||
expect(require(
|
||||
number === 1 ? "./folder/file1" :
|
||||
number === 2 ? "./folder/file2" :
|
||||
number === 3 ? "./folder/file3" :
|
||||
"./missingModule"
|
||||
expect()).toBe("file" + number);
|
||||
)).toBe("file" + number);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
it("should have __webpack_hash__", function() {
|
||||
expect(typeof __webpack_hash__).toBeTypeOf("string");
|
||||
expect(__webpack_hash__).toBeTypeOf("string");
|
||||
expect(__webpack_hash__).toMatch(/^[0-9a-f]{20}$/);
|
||||
});
|
||||
it("should have __webpack_chunkname__", function() {
|
||||
expect(typeof __webpack_chunkname__).toBeTypeOf("string");
|
||||
expect(__webpack_chunkname__).toBe('other');
|
||||
expect(__webpack_chunkname__).toBeTypeOf("string");
|
||||
expect(__webpack_chunkname__).toBe("other");
|
||||
});
|
||||
|
|
|
@ -2,7 +2,7 @@ it("should generate a events.json file", () => {
|
|||
var fs = require("fs"),
|
||||
path = require("path"),
|
||||
os = require("os");
|
||||
expect(fs.existsSync(path.join(os.tmpdir(), "events.json"))).toBe(true);
|
||||
expect(fs.existsSync(path.join(__dirname, "events.json"))).toBe(true);
|
||||
});
|
||||
|
||||
it("should have proper setup record inside of the json stream", () => {
|
||||
|
@ -11,6 +11,6 @@ it("should have proper setup record inside of the json stream", () => {
|
|||
os = require("os");
|
||||
|
||||
// convert json stream to valid
|
||||
var source = JSON.parse(fs.readFileSync(path.join(os.tmpdir(), "events.json"), "utf-8").toString() + "{}]");
|
||||
var source = JSON.parse(fs.readFileSync(path.join(__dirname, "events.json"), "utf-8").toString() + "{}]");
|
||||
expect(source[0].id).toEqual(1);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
var rootPath = "../../../../";
|
||||
var webpack = require(rootPath);
|
||||
var path = require("path");
|
||||
var os = require("os");
|
||||
|
||||
module.exports = {
|
||||
module.exports = (env, { testPath }) => ({
|
||||
plugins: [
|
||||
new webpack.debug.ProfilingPlugin({
|
||||
outPath: path.join(os.tmpdir(), "events.json")
|
||||
outPath: path.join(testPath, "events.json")
|
||||
})
|
||||
],
|
||||
node: {
|
||||
__dirname: false,
|
||||
__filename: false
|
||||
}
|
||||
};
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue