Skip to content

Commit a6c2aca

Browse files
committed
migrate should to expect, part 2 (manual)
1 parent 5a8083a commit a6c2aca

File tree

108 files changed

+421
-410
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+421
-410
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@
117117
"publish-patch": "npm run lint && npm run beautify-lint && mocha && npm version patch && git push && git push --tags && npm publish"
118118
},
119119
"jest": {
120-
"testEnvironment": "node"
120+
"testEnvironment": "node",
121+
"setupTestFrameworkScriptFile": "<rootDir>/test/setupTestFramework.js"
121122
}
122123
}

test/browsertest/lib/index.web.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ describe("main", function() {
2020
expect(window.library2common.ok2).toEqual(expect.anything());
2121
expect(window.library2common.ok2).toBe(true);
2222
expect(window.library2).toEqual(expect.anything());
23-
expect(window.library2.ok).toEqual(expect.anything());
24-
expect(window.library2.ok).toBe(true);
23+
expect(window.toBeTruthy()).toEqual(expect.anything());
24+
expect(window.toBeTruthy()).toBe(true);
2525
});
2626

2727
describe("web resolving", function() {
@@ -32,16 +32,16 @@ describe("main", function() {
3232
it("should load correct replacements for files", function(done) {
3333
require.ensure(["subcontent"], function(require) {
3434
// Comments work!
35-
exports.ok = true;
35+
exports.toBeTruthy() = true;
3636
test(require("subcontent") === "replaced", "node_modules should be replaced with web_modules");
3737
test(require("subcontent2/file.js") === "orginal", "node_modules should still work when web_modules exists");
3838
done();
3939
});
4040
});
4141

4242
after(function() {
43-
expect(exports.ok).toEqual(expect.anything());
44-
expect(exports.ok).toBe(true);
43+
expect(exports.toBeTruthy()).toEqual(expect.anything());
44+
expect(exports.toBeTruthy()).toBe(true);
4545
});
4646
});
4747

test/cases/chunks/context-weak/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
it("should not bundle context requires with asyncMode === 'weak'", function() {
22
var contextRequire = require.context(".", false, /two/, "weak");
3-
(function() {
3+
expect(function() {
44
contextRequire("./two")
5-
}).should.throw(/not available/);
5+
}).toThrowError(/not available/);
66
});
77

88
it("should find module with asyncMode === 'weak' when required elsewhere", function() {

test/cases/chunks/inline-options/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,15 @@ it("should not find module when mode is weak and chunk not served elsewhere", fu
9191
var name = "a";
9292
return import(/* webpackMode: "weak" */ "./dir10/" + name)
9393
.catch(function(e) {
94-
e.should.match({ message: /not available/, code: /MODULE_NOT_FOUND/ });
95-
})
94+
expect(e).toMatchObject({ message: /not available/, code: /MODULE_NOT_FOUND/ });
95+
});
9696
});
9797

9898
it("should not find module when mode is weak and chunk not served elsewhere (without context)", function() {
9999
return import(/* webpackMode: "weak" */ "./dir11/a")
100100
.catch(function(e) {
101-
e.should.match({ message: /not available/, code: /MODULE_NOT_FOUND/ });
102-
})
101+
expect(e).toMatchObject({ message: /not available/, code: /MODULE_NOT_FOUND/ });
102+
});
103103
});
104104

105105
function testChunkLoading(load, expectedSyncInitial, expectedSyncRequested) {

test/cases/chunks/named-chunks/index.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ it("should handle named chunks", function(done) {
1313
require.ensure([], function(require) {
1414
require("./empty?c");
1515
require("./empty?d");
16-
sync.should.be.ok();
16+
expect(sync).toBeTruthy();
1717
done();
1818
}, "named-chunk");
1919
}
@@ -22,10 +22,10 @@ it("should handle named chunks", function(done) {
2222
it("should handle empty named chunks", function(done) {
2323
var sync = false;
2424
require.ensure([], function(require) {
25-
sync.should.be.ok();
25+
expect(sync).toBeTruthy();
2626
}, "empty-named-chunk");
2727
require.ensure([], function(require) {
28-
sync.should.be.ok();
28+
expect(sync).toBeTruthy();
2929
done();
3030
}, "empty-named-chunk");
3131
sync = true;
@@ -49,7 +49,7 @@ it("should handle named chunks when there is an error callback", function(done)
4949
require.ensure([], function(require) {
5050
require("./empty?g");
5151
require("./empty?h");
52-
sync.should.be.ok();
52+
expect(sync).toBeTruthy();
5353
done();
5454
}, function(error) {}, "named-chunk-for-error-callback");
5555
}
@@ -58,10 +58,10 @@ it("should handle named chunks when there is an error callback", function(done)
5858
it("should handle empty named chunks when there is an error callback", function(done) {
5959
var sync = false;
6060
require.ensure([], function(require) {
61-
sync.should.be.ok();
61+
expect(sync).toBeTruthy();
6262
}, function(error) {}, "empty-named-chunk-for-error-callback");
6363
require.ensure([], function(require) {
64-
sync.should.be.ok();
64+
expect(sync).toBeTruthy();
6565
done();
6666
}, function(error) {}, "empty-named-chunk-for-error-callback");
6767
sync = true;
@@ -75,13 +75,13 @@ it("should be able to use named chunks in import()", function(done) {
7575
import("./empty?import1-in-chunk1" /* webpackChunkName: "import-named-chunk-1" */).then(function(result){
7676
var i = 0;
7777
import("./empty?import2-in-chunk1" /* webpackChunkName: "import-named-chunk-1" */).then(function(result){
78-
sync.should.be.ok();
78+
expect(sync).toBeTruthy();
7979
if(i++ > 0) done();
8080
}).catch(function(err){
8181
done(err);
8282
});
8383
import("./empty?import3-in-chunk2" /* webpackChunkName: "import-named-chunk-2" */).then(function(result){
84-
sync.should.not.be.ok();
84+
expect(sync).toBeFalsy();
8585
if(i++ > 0) done();
8686
}).catch(function(err){
8787
done(err);
@@ -99,13 +99,13 @@ it("should be able to use named chunk in context import()", function(done) {
9999
import("./e" + mpty + "2" /* webpackChunkName: "context-named-chunk" */).then(function(result) {
100100
var i = 0;
101101
import("./e" + mpty + "3" /* webpackChunkName: "context-named-chunk" */).then(function(result){
102-
sync.should.be.ok();
102+
expect(sync).toBeTruthy();
103103
if(i++ > 0) done();
104104
}).catch(function(err){
105105
done(err);
106106
});
107107
import("./e" + mpty + "4" /* webpackChunkName: "context-named-chunk-2" */).then(function(result){
108-
sync.should.not.be.ok();
108+
expect(sync).toBeFalsy();
109109
if(i++ > 0) done();
110110
}).catch(function(err){
111111
done(err);

test/cases/chunks/parsing/index.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
var should = require("should");
2-
31
it("should handle bound function expressions", function(done) {
42
require.ensure([], function(require) {
53
expect(this).toEqual({ test: true });
64
require("./empty?test");
7-
process.nextTick.should.have.type("function"); // check if injection still works
5+
expect(process.nextTick).toBeTypeOf("function"); // check if injection still works
86
require.ensure([], function(require) {
97
expect(this).toEqual({ test: true });
108
done();
@@ -35,7 +33,7 @@ it("should accept a require.include call", function(done) {
3533
value = require("./require.include");
3634
});
3735
setImmediate(function() {
38-
should.strictEqual(value, "require.include");
36+
expect(value).toBe("require.include");
3937
expect(value).toBe("require.include");
4038
done();
4139
});

test/cases/chunks/weak-dependencies-context/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ it("should not include a module with a weak dependency using context", function(
1414
require(["./b"]);
1515
require("./c");
1616

17-
resolveWeakA.should.exist;
18-
resolveWeakB.should.exist;
19-
resolveWeakC.should.exist;
17+
expect(resolveWeakA).toBeDefined();
18+
expect(resolveWeakB).toBeDefined();
19+
expect(resolveWeakC).toBeDefined();
2020

2121
expect(a).toBe(false);
2222
expect(b).toBe(false);
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
it("should hide stack in details", function() {
2-
(function f() {
2+
expect(function f() {
33
require("./loader!");
4-
}).should.throw();
4+
}).toThrowError();
55
});
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
it("should ignore hidden files", function() {
2-
(function() {
2+
expect(function() {
33
var name = "./file.js";
44
require("./folder/" + name);
5-
}).should.throw();
5+
}).toThrowError();
66
});

test/cases/context/issue-1769/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ it("should be able the catch a incorrect import", function(done) {
33
import("./folder/" + expr).then(function() {
44
done(new Error("should not be called"));
55
}).catch(function(err) {
6-
err.should.be.instanceof(Error);
6+
expect(err).toBeInstanceOf(Error);
77
done();
88
});
99
});

0 commit comments

Comments
 (0)