Skip to content

Commit

Permalink
test: Fix flaky tests after #4811 due to bad assumptions (#4852)
Browse files Browse the repository at this point in the history
**Summary**

Tests started failing on Travis after #4811, somewhat randomly, due to them expecting the unwrapped
output. This PR fixes those expectations and moves normalize-manifest tests to snapshots since
that's easier than updating 40+ JSON files by hand.

**Test plan**

Tests should pass on all platforms and CI and locally.
  • Loading branch information
BYK authored Nov 6, 2017
1 parent 5c4b6f3 commit c5e2dc5
Show file tree
Hide file tree
Showing 47 changed files with 227 additions and 83 deletions.
211 changes: 211 additions & 0 deletions __tests__/__snapshots__/normalize-manifest.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`author object normalize 1`] = `
Array [
"No license field",
]
`;

exports[`author string 1`] = `
Array [
"No license field",
]
`;

exports[`authors file to contributors 1`] = `
Array [
"No license field",
]
`;

exports[`bin string 1`] = `
Array [
"foo: No license field",
]
`;

exports[`binding.gyp scripts.install 1`] = `
Array [
"No license field",
]
`;

exports[`bugs string 1`] = `
Array [
"No license field",
]
`;

exports[`bundledDependencies alias 1`] = `
Array [
"No license field",
]
`;

exports[`clean version 1`] = `
Array [
"No license field",
]
`;

exports[`clean version with v 1`] = `
Array [
"No license field",
]
`;

exports[`contributors array expand 1`] = `
Array [
"No license field",
]
`;

exports[`dedupe all trivial dependencies 1`] = `
Array [
"No license field",
]
`;

exports[`dedupe dependencies 1`] = `Array []`;

exports[`dedupe dependencies root 1`] = `
Array [
"No license field",
"\\"dependencies\\" has dependency \\"foobar\\" with range \\"2.0.0\\" that collides with a dependency in \\"devDependencies\\" of the same name with version \\"1.0.0\\"",
]
`;

exports[`dedupe optionalDependencies 1`] = `Array []`;

exports[`dedupe optionalDependencies root 1`] = `
Array [
"No license field",
"\\"optionalDependencies\\" has dependency \\"foobar\\" with range \\"1.0.0\\" that collides with a dependency in \\"dependencies\\" of the same name with version \\"2.0.0\\"",
]
`;

exports[`dedupe single trivial dependency 1`] = `
Array [
"No license field",
]
`;

exports[`engines array 1`] = `
Array [
"No license field",
]
`;

exports[`explode directories.bin 1`] = `
Array [
"No license field",
]
`;

exports[`explode directories.man 1`] = `
Array [
"No license field",
]
`;

exports[`extract description 1`] = `
Array [
"No license field",
]
`;

exports[`homepage string 1`] = `
Array [
"No license field",
]
`;

exports[`hosted git repository url 1`] = `
Array [
"No license field",
]
`;

exports[`keywords string 1`] = `
Array [
"No license field",
]
`;

exports[`license warnings should not be thrown with global commands 1`] = `Array []`;

exports[`maintainers array expand 1`] = `
Array [
"No license field",
]
`;

exports[`man string 1`] = `
Array [
"No license field",
]
`;

exports[`name 1`] = `
Array [
"foobar: No license field",
]
`;

exports[`readme 1`] = `
Array [
"No license field",
]
`;

exports[`repository string 1`] = `
Array [
"No license field",
]
`;

exports[`scoped bin string 1`] = `
Array [
"@scope/foo: No license field",
]
`;

exports[`server scripts.start 1`] = `
Array [
"No license field",
]
`;

exports[`valid license 1`] = `Array []`;

exports[`version 1`] = `
Array [
"No license field",
]
`;

exports[`warn builtin module collision 1`] = `
Array [
"fs: \\"fs\\" is also the name of a node core module",
"fs: No license field",
]
`;

exports[`warn empty string invalid license 1`] = `
Array [
"License should be a valid SPDX license expression",
]
`;

exports[`warn invalid license 1`] = `
Array [
"License should be a valid SPDX license expression",
]
`;

exports[`warn typo 1`] = `
Array [
"Potential typo \\"dependancies\\", did you mean \\"dependencies\\"?",
"No license field",
]
`;
2 changes: 1 addition & 1 deletion __tests__/commands/install/bin-links.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function execCommand(cwd: string, binPath: Array<string>, args: Array<string>):
cwd,
env: {
...process.env,
YARN_SILENT: 0,
YARN_WRAP_OUTPUT: 1,
},
},
(error, stdout) => {
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion __tests__/fixtures/normalize-manifest/name/warnings.json

This file was deleted.

1 change: 0 additions & 1 deletion __tests__/fixtures/normalize-manifest/readme/warnings.json

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

4 changes: 0 additions & 4 deletions __tests__/fixtures/normalize-manifest/warn typo/warnings.json

This file was deleted.

3 changes: 2 additions & 1 deletion __tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ async function execCommand(
return new Promise((resolve, reject) => {
const cleanedEnv = {...process.env};
cleanedEnv['YARN_SILENT'] = 0;
cleanedEnv['YARN_WRAP_OUTPUT'] = 1;
delete cleanedEnv['FORCE_COLOR'];

exec(
Expand Down Expand Up @@ -121,7 +122,7 @@ test.concurrent('should add package with no-lockfile option', async () => {
expectAddSuccessfullOutputWithNoLockFile(stdout, 'repeating');
});

test.concurrent('should add package with frozzen-lockfile option', async () => {
test.concurrent('should add package with frozen-lockfile option', async () => {
const stdout = await execCommand('add', ['repeating', '--frozen-lockfile'], 'run-add-option', true);
expectAddSuccessfullOutputWithNoLockFile(stdout, 'repeating');
});
Expand Down
2 changes: 1 addition & 1 deletion __tests__/lifecycle-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async function execCommand(cmd: string, packageName: string, env = process.env):

return new Promise((resolve, reject) => {
const cleanedEnv = {...env};
cleanedEnv['YARN_SILENT'] = 0;
cleanedEnv['YARN_WRAP_OUTPUT'] = 1;
delete cleanedEnv['FORCE_COLOR'];

exec(
Expand Down
Loading

0 comments on commit c5e2dc5

Please sign in to comment.