Skip to content

Commit 1159935

Browse files
committed
change tests to Jest
1 parent 3e66954 commit 1159935

2 files changed

Lines changed: 57 additions & 73 deletions

File tree

‎test/Errors.test.js‎

Lines changed: 55 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -205,14 +205,14 @@ describe("Errors", () => {
205205
entry: "./entry-point-error-loader-required.js"
206206
},
207207
(errors, warnings) => {
208-
warnings.length.should.be.eql(1);
209-
warnings[0]
210-
.split("\n")[1]
211-
.should.match(/^Module Warning \(from .\/emit-error-loader.js\):$/);
212-
errors.length.should.be.eql(1);
213-
errors[0]
214-
.split("\n")[1]
215-
.should.match(/^Module Error \(from .\/emit-error-loader.js\):$/);
208+
expect(warnings).toHaveLength(1);
209+
expect(warnings[0].split("\n")[1]).toMatch(
210+
/^Module Warning \(from .\/emit-error-loader.js\):$/
211+
);
212+
expect(errors).toHaveLength(1);
213+
expect(errors[0].split("\n")[1]).toMatch(
214+
/^Module Error \(from .\/emit-error-loader.js\):$/
215+
);
216216
}
217217
),
218218
getErrorsPromise(
@@ -221,14 +221,14 @@ describe("Errors", () => {
221221
entry: path.resolve(base, "./emit-error-loader") + "!./entry-point.js"
222222
},
223223
(errors, warnings) => {
224-
warnings.length.should.be.eql(1);
225-
warnings[0]
226-
.split("\n")[1]
227-
.should.match(/^Module Warning \(from .\/emit-error-loader.js\):$/);
228-
errors.length.should.be.eql(1);
229-
errors[0]
230-
.split("\n")[1]
231-
.should.match(/^Module Error \(from .\/emit-error-loader.js\):$/);
224+
expect(warnings).toHaveLength(1);
225+
expect(warnings[0].split("\n")[1]).toMatch(
226+
/^Module Warning \(from .\/emit-error-loader.js\):$/
227+
);
228+
expect(errors).toHaveLength(1);
229+
expect(errors[0].split("\n")[1]).toMatch(
230+
/^Module Error \(from .\/emit-error-loader.js\):$/
231+
);
232232
}
233233
),
234234
getErrorsPromise(
@@ -250,19 +250,17 @@ describe("Errors", () => {
250250
}
251251
},
252252
(errors, warnings) => {
253-
warnings.length.should.be.eql(1);
254-
warnings[0]
255-
.split("\n")[1]
256-
.should.match(/^Module Warning \(from .\/emit-error-loader.js\):$/);
257-
errors.length.should.be.eql(2);
258-
errors[0]
259-
.split("\n")[1]
260-
.should.match(/^Module Error \(from .\/emit-error-loader.js\):$/);
261-
errors[1]
262-
.split("\n")[1]
263-
.should.match(
264-
/^Module build failed \(from \(webpack\)\/node_modules\/json-loader\/index.js\):$/
265-
);
253+
expect(warnings).toHaveLength(1);
254+
expect(warnings[0].split("\n")[1]).toMatch(
255+
/^Module Warning \(from .\/emit-error-loader.js\):$/
256+
);
257+
expect(errors).toHaveLength(2);
258+
expect(errors[0].split("\n")[1]).toMatch(
259+
/^Module Error \(from .\/emit-error-loader.js\):$/
260+
);
261+
expect(errors[1].split("\n")[1]).toMatch(
262+
/^Module build failed \(from \(webpack\)\/node_modules\/json-loader\/index.js\):$/
263+
);
266264
}
267265
),
268266
getErrorsPromise(
@@ -279,12 +277,10 @@ describe("Errors", () => {
279277
}
280278
},
281279
(errors, warnings) => {
282-
errors.length.should.be.eql(1);
283-
errors[0]
284-
.split("\n")[1]
285-
.should.match(
286-
/^Module build failed \(from .\/async-error-loader.js\):$/
287-
);
280+
expect(errors).toHaveLength(1);
281+
expect(errors[0].split("\n")[1]).toMatch(
282+
/^Module build failed \(from .\/async-error-loader.js\):$/
283+
);
288284
}
289285
),
290286
getErrorsPromise(
@@ -301,12 +297,10 @@ describe("Errors", () => {
301297
}
302298
},
303299
(errors, warnings) => {
304-
errors.length.should.be.eql(1);
305-
errors[0]
306-
.split("\n")[1]
307-
.should.match(
308-
/^Module build failed \(from .\/throw-error-loader.js\):$/
309-
);
300+
expect(errors).toHaveLength(1);
301+
expect(errors[0].split("\n")[1]).toMatch(
302+
/^Module build failed \(from .\/throw-error-loader.js\):$/
303+
);
310304
}
311305
),
312306
getErrorsPromise(
@@ -323,34 +317,24 @@ describe("Errors", () => {
323317
}
324318
},
325319
(errors, warnings) => {
326-
warnings.length.should.be.eql(2);
327-
warnings[0]
328-
.split("\n")[1]
329-
.should.match(
330-
/^Module Warning \(from .\/irregular-error-loader.js\):$/
331-
);
332-
warnings[1]
333-
.split("\n")[1]
334-
.should.match(
335-
/^Module Warning \(from .\/irregular-error-loader.js\):$/
336-
);
320+
expect(warnings).toHaveLength(2);
321+
expect(warnings[0].split("\n")[1]).toMatch(
322+
/^Module Warning \(from .\/irregular-error-loader.js\):$/
323+
);
324+
expect(warnings[1].split("\n")[1]).toMatch(
325+
/^Module Warning \(from .\/irregular-error-loader.js\):$/
326+
);
337327

338-
errors.length.should.be.eql(3);
339-
errors[0]
340-
.split("\n")[1]
341-
.should.match(
342-
/^Module Error \(from .\/irregular-error-loader.js\):$/
343-
);
344-
errors[1]
345-
.split("\n")[1]
346-
.should.match(
347-
/^Module Error \(from .\/irregular-error-loader.js\):$/
348-
);
349-
errors[2]
350-
.split("\n")[1]
351-
.should.match(
352-
/^Module build failed \(from .\/irregular-error-loader.js\):$/
353-
);
328+
expect(errors).toHaveLength(3);
329+
expect(errors[0].split("\n")[1]).toMatch(
330+
/^Module Error \(from .\/irregular-error-loader.js\):$/
331+
);
332+
expect(errors[1].split("\n")[1]).toMatch(
333+
/^Module Error \(from .\/irregular-error-loader.js\):$/
334+
);
335+
expect(errors[2].split("\n")[1]).toMatch(
336+
/^Module build failed \(from .\/irregular-error-loader.js\):$/
337+
);
354338
}
355339
)
356340
]);
@@ -362,10 +346,10 @@ describe("Errors", () => {
362346
entry: path.resolve(base, "./no-return-loader") + "!./entry-point.js"
363347
},
364348
(errors, warnings) => {
365-
errors.length.should.be.eql(1);
349+
expect(errors).toHaveLength(1);
366350
const messages = errors[0].split("\n");
367-
messages[1].should.match(/^Module build failed:$/);
368-
messages[2].should.match(/didn't return/);
351+
expect(messages[1]).toMatch(/^Module build failed:$/);
352+
expect(messages[2]).toMatch(/didn't return/);
369353
done();
370354
}
371355
);
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
it("should not crash when scope-hoisted modules change", function() {
2-
require("./module").default.should.be.eql(WATCH_STEP);
3-
})
2+
expect(require("./module").default).toBe(WATCH_STEP);
3+
});

0 commit comments

Comments
 (0)