Skip to content

fix(test): replace include.toBeTruthy with toContain #2324

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 18 additions & 24 deletions test/cli/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,25 @@ describe('CLI', () => {
testBin('--progress')
.then((output) => {
expect(output.code).toEqual(0);
expect(output.stderr.includes('0% compiling')).toBe(true);
expect(output.stderr).toContain('0% compiling');
// should not profile
expect(
output.stderr.includes('ms after chunk modules optimization')
).toBe(false);
expect(output.stderr).not.toContain(
'ms after chunk modules optimization'
);
done();
})
.catch(done);
});

it('--quiet', async (done) => {
const output = await testBin(`--quiet --port ${port1}`);
const output = await testBin(`--quiet --colors=false --port ${port1}`);
expect(output.code).toEqual(0);
expect(output.stdout.split('\n').length === 3).toBe(true);
expect(
output.stdout.includes(`Project is running at http://localhost:${port1}/`)
).toBe(true);
expect(output.stdout.includes('webpack output is served from /')).toBe(
true
expect(output.stdout).toContain(
`Project is running at http://localhost:${port1}/`
);
expect(
output.stdout.includes('Content not from webpack is served from')
).toBe(true);
expect(output.stdout).toContain('webpack output is served from /');
expect(output.stdout).toContain('Content not from webpack is served from');
done();
});

Expand All @@ -51,9 +47,7 @@ describe('CLI', () => {
.then((output) => {
expect(output.code).toEqual(0);
// should profile
expect(output.stderr.includes('after chunk modules optimization')).toBe(
true
);
expect(output.stderr).toContain('after chunk modules optimization');
done();
})
.catch(done);
Expand All @@ -63,7 +57,7 @@ describe('CLI', () => {
testBin('--bonjour')
.then((output) => {
expect(output.code).toEqual(0);
expect(output.stdout.includes('Bonjour')).toBe(true);
expect(output.stdout).toContain('Bonjour');
done();
})
.catch(done);
Expand All @@ -73,7 +67,7 @@ describe('CLI', () => {
testBin('--https')
.then((output) => {
expect(output.code).toEqual(0);
expect(output.stdout.includes('Project is running at')).toBe(true);
expect(output.stdout).toContain('Project is running at');
done();
})
.catch(done);
Expand All @@ -85,7 +79,7 @@ describe('CLI', () => {
)
.then((output) => {
expect(output.code).toEqual(0);
expect(output.stdout.includes('Project is running at')).toBe(true);
expect(output.stdout).toContain('Project is running at');
done();
})
.catch(done);
Expand Down Expand Up @@ -115,9 +109,9 @@ describe('CLI', () => {
testBin('--color')
.then((output) => {
// https://github.com/webpack/webpack-dev-server/blob/master/lib/utils/colors.js
expect(
output.stdout.includes('\u001b[39m \u001b[90m「wds」\u001b[39m:')
).toEqual(true);
expect(output.stdout).toContain(
'\u001b[39m \u001b[90m「wds」\u001b[39m:'
);
done();
})
.catch(done);
Expand All @@ -134,7 +128,7 @@ describe('CLI', () => {
if (process.platform === 'win32') {
done();
} else {
expect(output.stdout.includes(socketPath)).toBe(true);
expect(output.stdout).toContain(socketPath);

unlink(socketPath, () => {
done();
Expand All @@ -155,7 +149,7 @@ describe('CLI', () => {
})
.catch((err) => {
// for windows
expect(err.stdout.includes('Compiled successfully.')).toEqual(true);
expect(err.stdout).toContain('Compiled successfully.');
done();
});
});
Expand Down
40 changes: 15 additions & 25 deletions test/e2e/ClientOptions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,9 @@ describe('Client code', () => {
.then((requestObj) => {
page.waitFor(beforeBrowserCloseDelay).then(() => {
browser.close().then(() => {
expect(
requestObj
.url()
.includes(`http://localhost:${port1}/sockjs-node`)
).toBeTruthy();
expect(requestObj.url()).toContain(
`http://localhost:${port1}/sockjs-node`
);
done();
});
});
Expand Down Expand Up @@ -115,11 +113,9 @@ describe('Client complex inline script path', () => {
.then((requestObj) => {
page.waitFor(beforeBrowserCloseDelay).then(() => {
browser.close().then(() => {
expect(
requestObj
.url()
.includes(`http://myhost.test:${port2}/foo/test/bar/`)
).toBeTruthy();
expect(requestObj.url()).toContain(
`http://myhost.test:${port2}/foo/test/bar/`
);
done();
});
});
Expand Down Expand Up @@ -158,11 +154,9 @@ describe('Client complex inline script path with sockPort', () => {
.then((requestObj) => {
page.waitFor(beforeBrowserCloseDelay).then(() => {
browser.close().then(() => {
expect(
requestObj
.url()
.includes(`http://localhost:${port3}/foo/test/bar`)
).toBeTruthy();
expect(requestObj.url()).toContain(
`http://localhost:${port3}/foo/test/bar`
);
done();
});
});
Expand Down Expand Up @@ -202,11 +196,9 @@ describe('Client complex inline script path with sockPort, no sockPath', () => {
.then((requestObj) => {
page.waitFor(beforeBrowserCloseDelay).then(() => {
browser.close().then(() => {
expect(
requestObj
.url()
.includes(`http://localhost:${port3}/sockjs-node`)
).toBeTruthy();
expect(requestObj.url()).toContain(
`http://localhost:${port3}/sockjs-node`
);
done();
});
});
Expand Down Expand Up @@ -242,11 +234,9 @@ describe('Client complex inline script path with sockHost', () => {
.then((requestObj) => {
page.waitFor(beforeBrowserCloseDelay).then(() => {
browser.close().then(() => {
expect(
requestObj
.url()
.includes(`http://myhost.test:${port2}/sockjs-node`)
).toBeTruthy();
expect(requestObj.url()).toContain(
`http://myhost.test:${port2}/sockjs-node`
);
done();
});
});
Expand Down