Skip to content

Commit

Permalink
tests(binTestCases): refactor to make tests pass (#472)
Browse files Browse the repository at this point in the history
  • Loading branch information
evenstensberg authored May 31, 2018
1 parent c2398a2 commit 3442865
Show file tree
Hide file tree
Showing 18 changed files with 34 additions and 34 deletions.
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
**/__testfixtures__/*
coverage
test
docs
docs
node_modules
4 changes: 2 additions & 2 deletions test/BinTestCases.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ describe("BinTestCases", function() {
try {
testAssertions(env.code, stdout, stderr);
} catch(e) {
console.log(`### stderr ###\n${env.stderr.join("")}`);
console.log(`### stdout ###\n${env.stdout.join("")}`);
// console.log(`### stderr ###\n${env.stderr.join("")}`);
// console.log(`### stdout ###\n${env.stdout.join("")}`);
throw e;
}
});
Expand Down
4 changes: 2 additions & 2 deletions test/binCases/config-name/found-many/stdin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module.exports = function testAssertions(code, stdout, stderr) {
expect(code).toBe(0);
expect(stdout).toEqual(expect.anything());
expect(stdout[9]).toContain("./index2.js");
expect(stdout[17]).toContain("./index3.js");
expect(stdout[8]).toContain("./index2.js");
expect(stdout[15]).toContain("./index3.js");
expect(stderr).toHaveLength(0);
};
3 changes: 1 addition & 2 deletions test/binCases/config-name/found-one/stdin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
module.exports = function testAssertions(code, stdout, stderr) {
expect(code).toBe(0);
expect(stdout).toEqual(expect.anything());

expect(stdout[7]).toContain("./index2.js");
expect(stdout[6]).toContain("./index2.js");
expect(stderr).toHaveLength(0);
};
4 changes: 2 additions & 2 deletions test/binCases/config-type/array/stdin.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = function testAssertions(code, stdout, stderr) {
expect(stdout[1]).toContain("Version: ");
expect(stdout[2]).toContain("Child");
expect(stdout[7]).toContain("entry-a.bundle.js");
expect(stdout[10]).toContain("Child");
expect(stdout[15]).toContain("entry-b.bundle.js");
expect(stdout[9]).toContain("Child");
expect(stdout[14]).toContain("entry-b.bundle.js");
expect(stderr).toHaveLength(0);
};
2 changes: 1 addition & 1 deletion test/binCases/configFile/plugins-precedence/stdin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
module.exports = function testAssertions(code, stdout, stderr) {
expect(code).toBe(0);
expect(stdout).toEqual(expect.anything());
expect(stdout[7]).toContain("ok.js");
expect(stdout[6]).toContain("ok.js");
expect(stderr).toHaveLength(0);
};
6 changes: 3 additions & 3 deletions test/binCases/configFile/profile/stdin.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ module.exports = function testAssertions(code, stdout, stderr) {
expect(code).toBe(0);
expect(stdout).toEqual(expect.anything());

expect(stdout[8]).toContain("factory:");
expect(stdout[10]).toContain("factory:");
expect(stdout[12]).toContain("factory:");
expect(stdout[7]).toContain("factory:");
expect(stdout[9]).toContain("factory:");
expect(stdout[11]).toContain("factory:");
expect(stderr).toHaveLength(0);
};
2 changes: 1 addition & 1 deletion test/binCases/entry/cli-override/stdin.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ module.exports = function testAssertions(code, stdout, stderr) {
expect(code).toBe(0);
expect(stdout).toEqual(expect.anything());
expect(stdout[5]).toContain("cliEntry.js");
expect(stdout[7]).toContain("index.js");
expect(stdout[6]).toContain("index.js");
expect(stderr).toHaveLength(0);
};
6 changes: 3 additions & 3 deletions test/binCases/entry/multi-file/stdin.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ module.exports = function testAssertions(code, stdout, stderr) {
expect(code).toBe(0);
expect(stdout).toEqual(expect.anything());
expect(stdout[5]).toContain("null.js");
expect(stdout[7]).toMatch(/a\.js.*\{0\}/);
expect(stdout[8]).toMatch(/index\.js.*\{0\}/);
expect(stdout[9]).toMatch(/multi.*index\.js.*a\.js/); // should have multi-file entry
expect(stdout[6]).toMatch(/a\.js.*\{0\}/);
expect(stdout[7]).toMatch(/index\.js.*\{0\}/);
expect(stdout[8]).toMatch(/multi.*index\.js.*a\.js/); // should have multi-file entry
expect(stderr).toHaveLength(0);
};
6 changes: 3 additions & 3 deletions test/binCases/entry/named-entry/stdin.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ module.exports = function testAssertions(code, stdout, stderr) {
expect(code).toBe(0);
expect(stdout).toEqual(expect.anything());
expect(stdout[5]).toContain("null.js");
expect(stdout[7]).toContain("foo.js"); // named entry from --entry foo=./a.js
expect(stdout[9]).toMatch(/index\.js.*\{0\}/);
expect(stdout[10]).toMatch(/a\.js.*\{1\}/);
expect(stdout[6]).toContain("foo.js"); // named entry from --entry foo=./a.js
expect(stdout[7]).toMatch(/index\.js.*\{0\}/);
expect(stdout[8]).toMatch(/a\.js.*\{1\}/);
expect(stderr).toHaveLength(0);
};
2 changes: 1 addition & 1 deletion test/binCases/entry/non-hyphenated-args/stdin.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ module.exports = function testAssertions(code, stdout, stderr) {
expect(code).toBe(0);
expect(stdout).toEqual(expect.anything());
expect(stdout[5]).toContain("main.js"); // non-hyphenated arg ./a.js should create chunk "main"
expect(stdout[7]).toMatch(/a\.js.*\{0\}/); // a.js should be in chunk 0
expect(stdout[6]).toMatch(/a\.js.*\{0\}/); // a.js should be in chunk 0
expect(stderr).toHaveLength(0);
};
4 changes: 2 additions & 2 deletions test/binCases/env/complex/stdin.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = function testAssertions(code, stdout, stderr) {
expect(stdout[9]).toContain("\"baz\": true");
expect(stdout[10]).toContain("}");
expect(stdout[12]).toContain("null.js");
expect(stdout[14]).toContain("./index.js");
expect(stdout[14]).toContain("[built]");
expect(stdout[13]).toContain("./index.js");
expect(stdout[13]).toContain("[built]");
expect(stderr).toHaveLength(0);
};
2 changes: 1 addition & 1 deletion test/binCases/env/string/stdin.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ module.exports = function testAssertions(code, stdout, stderr) {
expect(stdout[1]).toContain("Version: ");
expect(stdout[2]).toContain("Time: ");
expect(stdout[4]).toContain("Environment (--env): \"foo\"");
expect(stdout[7]).toContain("null.js");
expect(stdout[6]).toContain("null.js");
expect(stderr).toHaveLength(0);
};
2 changes: 1 addition & 1 deletion test/binCases/errors/issue-5576/stdin.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = function testAssertions(code, stdout, stderr) {
expect(stdout[0]).toContain("Hash: ");
expect(stdout[1]).toContain("Version: ");
expect(stdout[2]).toContain("Time: ");
expect(stdout[6]).toContain("bundle.js");
expect(stdout[5]).toContain("bundle.js");

expect(stderr).toHaveLength(0);
};
12 changes: 6 additions & 6 deletions test/binCases/errors/parse/stdin.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ module.exports = function testAssertions(code, stdout, stderr) {
expect(stdout[0]).toContain("Hash: ");
expect(stdout[1]).toContain("Version: ");
expect(stdout[2]).toContain("Time: ");
expect(stdout[6]).toContain("./index.js");
expect(stdout[6]).toContain("[built]");
expect(stdout[6]).toContain("[failed]");
expect(stdout[6]).toContain("[1 error]");
expect(stdout[8]).toContain("ERROR in ./index.js");
expect(stdout[9]).toContain("Module parse failed:");
expect(stdout[5]).toContain("./index.js");
expect(stdout[5]).toContain("[built]");
expect(stdout[5]).toContain("[failed]");
expect(stdout[5]).toContain("[1 error]");
expect(stdout[7]).toContain("ERROR in ./index.js");
expect(stdout[8]).toContain("Module parse failed:");

expect(stderr).toHaveLength(0);
};
2 changes: 1 addition & 1 deletion test/binCases/mode/none/stdin.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ module.exports = function testAssertions(code, stdout, stderr) {
expect(code).toBe(0);
expect(stdout).toEqual(expect.anything());
expect(stdout[5]).toContain("main.js");
expect(stdout[7]).toMatch(/index\.js.*\{0\}/);
expect(stdout[6]).toMatch(/index\.js.*\{0\}/);
expect(stderr).toHaveLength(0);
};
2 changes: 1 addition & 1 deletion test/binCases/output/output-argument/stdin.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ module.exports = function testAssertions(code, stdout, stderr) {
expect(code).toBe(0);
expect(stdout).toEqual(expect.anything());
expect(stdout[5]).toContain("bundle.js");
expect(stdout[7]).toMatch(/index\.js.*\{0\}/);
expect(stdout[6]).toMatch(/index\.js.*\{0\}/);
expect(stderr).toHaveLength(0);
};
2 changes: 1 addition & 1 deletion test/binCases/stats/single-config/stdin.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = function testAssertions(code, stdout, stderr) {
expect(stdout[1]).toContain("Version: ");
expect(stdout[2]).toContain("Time: ");
expect(stdout[5]).toContain("\u001b[1m\u001b[32mnull.js\u001b[39m\u001b[22m");
expect(stdout[7]).toContain("chunk");
expect(stdout[6]).toContain("chunk");
expect(stdout[7]).not.toContain("./index.js");
expect(stdout[7]).not.toContain("[built]");
expect(stdout[8]).toContain("1 module");
Expand Down

0 comments on commit 3442865

Please sign in to comment.