Skip to content
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

Human-readable colors for jest-matchers snapshots #3119

Merged
merged 3 commits into from
Mar 10, 2017
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
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"private": true,
"devDependencies": {
"ansi-regex": "^2.0.0",
"ansi-styles": "^3.0.0",
"babel-core": "^6.23.1",
"babel-eslint": "^7.1.1",
"babel-plugin-syntax-trailing-function-commas": "^6.13.0",
Expand Down Expand Up @@ -84,6 +86,9 @@
"^.+\\.js$": "<rootDir>/packages/babel-jest"
},
"setupTestFrameworkScriptFile": "<rootDir>/testSetupFile.js",
"snapshotSerializers": [
"<rootDir>/packages/pretty-format/build/plugins/ConvertAnsi.js"
],
"testEnvironment": "./packages/jest-environment-node",
"testPathIgnorePatterns": [
"/node_modules/",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`for multiline test name returns test name with highlighted pattern and replaced line breaks 1`] = `"should⏎ name the ⏎function you at..."`;
exports[`for multiline test name returns test name with highlighted pattern and replaced line breaks 1`] = `"<dim>should⏎ </>name</><dim> the ⏎function you at..."`;

exports[`for multiline test name returns test name with highlighted pattern and replaced line breaks 2`] = `"should⏎ name the ⏎function you at..."`;
exports[`for multiline test name returns test name with highlighted pattern and replaced line breaks 2`] = `"<dim>should⏎ </>name</><dim> the ⏎function you at..."`;

exports[`for multiline test name returns test name with highlighted pattern and replaced line breaks 3`] = `"should⏎ name the ⏎function you at..."`;
exports[`for multiline test name returns test name with highlighted pattern and replaced line breaks 3`] = `"<dim>should⏎ </>name</><dim> the ⏎function you at..."`;

exports[`for one line test name pattern in the middle test name with cutted tail and cutted highlighted pattern 1`] = `"should nam..."`;
exports[`for one line test name pattern in the middle test name with cutted tail and cutted highlighted pattern 1`] = `"<dim>should </>nam...</>"`;

exports[`for one line test name pattern in the middle test name with cutted tail and highlighted pattern 1`] = `"should name the functi..."`;
exports[`for one line test name pattern in the middle test name with cutted tail and highlighted pattern 1`] = `"<dim>should </>name</><dim> the functi..."`;

exports[`for one line test name pattern in the middle test name with highlighted cutted 1`] = `"sho..."`;
exports[`for one line test name pattern in the middle test name with highlighted cutted 1`] = `"<dim>sho</>...</>"`;

exports[`for one line test name pattern in the middle test name with highlighted pattern returns 1`] = `"should name the function you attach"`;
exports[`for one line test name pattern in the middle test name with highlighted pattern returns 1`] = `"<dim>should </>name</><dim> the function you attach"`;

exports[`for one line test name pattern in the tail returns test name with cutted tail and cutted highlighted pattern 1`] = `"should name the function you a..."`;
exports[`for one line test name pattern in the tail returns test name with cutted tail and cutted highlighted pattern 1`] = `"<dim>should name the function you </>a...</>"`;

exports[`for one line test name pattern in the tail returns test name with highlighted cutted 1`] = `"sho..."`;
exports[`for one line test name pattern in the tail returns test name with highlighted cutted 1`] = `"<dim>sho</>...</>"`;

exports[`for one line test name pattern in the tail returns test name with highlighted pattern 1`] = `"should name the function you attach"`;
exports[`for one line test name pattern in the tail returns test name with highlighted pattern 1`] = `"<dim>should name the function you </>attach</>"`;

exports[`for one line test name with pattern in the head returns test name with cutted tail and cutted highlighted pattern 1`] = `"shoul..."`;
exports[`for one line test name with pattern in the head returns test name with cutted tail and cutted highlighted pattern 1`] = `"</>shoul...</>"`;

exports[`for one line test name with pattern in the head returns test name with cutted tail and highlighted pattern 1`] = `"should name the function yo..."`;
exports[`for one line test name with pattern in the head returns test name with cutted tail and highlighted pattern 1`] = `"</>should</><dim> name the function yo..."`;

exports[`for one line test name with pattern in the head returns test name with highlighted pattern 1`] = `"should name the function you attach"`;
exports[`for one line test name with pattern in the head returns test name with highlighted pattern 1`] = `"</>should</><dim> name the function you attach"`;
Original file line number Diff line number Diff line change
@@ -1,77 +1,77 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`dims everything when there is no match 1`] = `"jest-cli/__tests__/watch-test.js"`;
exports[`dims everything when there is no match 1`] = `"<dim>jest-cli/__tests__/watch-test.js"`;

exports[`dims everything when there is no match 2`] = `"...t-cli/__tests__/watch-test.js"`;
exports[`dims everything when there is no match 2`] = `"<dim>...t-cli/__tests__/watch-test.js"`;

exports[`dims everything when there is no match 3`] = `".../__tests__/watch-test.js"`;
exports[`dims everything when there is no match 3`] = `"<dim>.../__tests__/watch-test.js"`;

exports[`dims everything when there is no match 4`] = `"...sts__/watch-test.js"`;
exports[`dims everything when there is no match 4`] = `"<dim>...sts__/watch-test.js"`;

exports[`dims everything when there is no match 5`] = `"...watch-test.js"`;
exports[`dims everything when there is no match 5`] = `"<dim>...watch-test.js"`;

exports[`dims everything when there is no match 6`] = `"...-test.js"`;
exports[`dims everything when there is no match 6`] = `"<dim>...-test.js"`;

exports[`dims everything when there is no match 7`] = `"....js"`;
exports[`dims everything when there is no match 7`] = `"<dim>....js"`;

exports[`dims everything when there is no match 8`] = `"./watch-test.js"`;
exports[`dims everything when there is no match 8`] = `"<dim>./watch-test.js"`;

exports[`highlight the trimmed part when there is only a rootDir match 1`] = `"jest-cli/__tests__/watch-test.js"`;
exports[`highlight the trimmed part when there is only a rootDir match 1`] = `"<dim>jest-cli/__tests__/watch-test.js"`;

exports[`highlight the trimmed part when there is only a rootDir match 2`] = `"...t-cli/__tests__/watch-test.js"`;
exports[`highlight the trimmed part when there is only a rootDir match 2`] = `"</>...</><dim>t-cli/__tests__/watch-test.js"`;

exports[`highlight the trimmed part when there is only a rootDir match 3`] = `".../__tests__/watch-test.js"`;
exports[`highlight the trimmed part when there is only a rootDir match 3`] = `"</>...</><dim>/__tests__/watch-test.js"`;

exports[`highlight the trimmed part when there is only a rootDir match 4`] = `"...sts__/watch-test.js"`;
exports[`highlight the trimmed part when there is only a rootDir match 4`] = `"</>...</><dim>sts__/watch-test.js"`;

exports[`highlight the trimmed part when there is only a rootDir match 5`] = `"...watch-test.js"`;
exports[`highlight the trimmed part when there is only a rootDir match 5`] = `"</>...</><dim>watch-test.js"`;

exports[`highlight the trimmed part when there is only a rootDir match 6`] = `"...-test.js"`;
exports[`highlight the trimmed part when there is only a rootDir match 6`] = `"</>...</><dim>-test.js"`;

exports[`highlight the trimmed part when there is only a rootDir match 7`] = `"....js"`;
exports[`highlight the trimmed part when there is only a rootDir match 7`] = `"</>...</><dim>.js"`;

exports[`highlight the trimmed part when there is only a rootDir match 8`] = `"./watch-test.js"`;
exports[`highlight the trimmed part when there is only a rootDir match 8`] = `"</>./</><dim>watch-test.js"`;

exports[`highlights everything when there is a full match 1`] = `"jest-cli/__tests__/watch-test.js"`;
exports[`highlights everything when there is a full match 1`] = `"</>jest-cli/__tests__/watch-test.js</>"`;

exports[`highlights everything when there is a full match 2`] = `"...t-cli/__tests__/watch-test.js"`;
exports[`highlights everything when there is a full match 2`] = `"</>...t-cli/__tests__/watch-test.js</>"`;

exports[`highlights everything when there is a full match 3`] = `".../__tests__/watch-test.js"`;
exports[`highlights everything when there is a full match 3`] = `"</>.../__tests__/watch-test.js</>"`;

exports[`highlights everything when there is a full match 4`] = `"...sts__/watch-test.js"`;
exports[`highlights everything when there is a full match 4`] = `"</>...sts__/watch-test.js</>"`;

exports[`highlights everything when there is a full match 5`] = `"...watch-test.js"`;
exports[`highlights everything when there is a full match 5`] = `"</>...watch-test.js</>"`;

exports[`highlights everything when there is a full match 6`] = `"...-test.js"`;
exports[`highlights everything when there is a full match 6`] = `"</>...-test.js</>"`;

exports[`highlights everything when there is a full match 7`] = `"....js"`;
exports[`highlights everything when there is a full match 7`] = `"</>....js</>"`;

exports[`highlights everything when there is a full match 8`] = `"./watch-test.js"`;
exports[`highlights everything when there is a full match 8`] = `"</>./watch-test.js</>"`;

exports[`highlights part of file name when there is a partially match of the file name 1`] = `"jest-cli/__tests__/watch-test.js"`;
exports[`highlights part of file name when there is a partially match of the file name 1`] = `"<dim>jest-cli/__tests__/</>watch</><dim>-test.js"`;

exports[`highlights part of file name when there is a partially match of the file name 2`] = `"...t-cli/__tests__/watch-test.js"`;
exports[`highlights part of file name when there is a partially match of the file name 2`] = `"<dim>...t-cli/__tests__/</>watch</><dim>-test.js"`;

exports[`highlights part of file name when there is a partially match of the file name 3`] = `".../__tests__/watch-test.js"`;
exports[`highlights part of file name when there is a partially match of the file name 3`] = `"<dim>.../__tests__/</>watch</><dim>-test.js"`;

exports[`highlights part of file name when there is a partially match of the file name 4`] = `"...sts__/watch-test.js"`;
exports[`highlights part of file name when there is a partially match of the file name 4`] = `"<dim>...sts__/</>watch</><dim>-test.js"`;

exports[`highlights part of file name when there is a partially match of the file name 5`] = `"...watch-test.js"`;
exports[`highlights part of file name when there is a partially match of the file name 5`] = `"<dim>...</>watch</><dim>-test.js"`;

exports[`highlights part of file name when there is a partially match of the file name 6`] = `"...-test.js"`;
exports[`highlights part of file name when there is a partially match of the file name 6`] = `"</>...</><dim>-test.js"`;

exports[`highlights part of file name when there is a partially match of the file name 7`] = `"....js"`;
exports[`highlights part of file name when there is a partially match of the file name 7`] = `"</>...</><dim>.js"`;

exports[`highlights part of file name when there is a partially match of the file name 8`] = `"./watch-test.js"`;
exports[`highlights part of file name when there is a partially match of the file name 8`] = `"<dim>./</>watch</><dim>-test.js"`;

exports[`highlights the trimmed part there is a non visible match 1`] = `"...t-cli/__tests__/watch-test.js"`;
exports[`highlights the trimmed part there is a non visible match 1`] = `"</>...t-cli</><dim>/__tests__/watch-test.js"`;

exports[`highlights the trimmed part there is a non visible match 2`] = `".../__tests__/watch-test.js"`;
exports[`highlights the trimmed part there is a non visible match 2`] = `"</>...</><dim>/__tests__/watch-test.js"`;

exports[`highlights the trimmed part there is a non visible match 3`] = `"...sts__/watch-test.js"`;
exports[`highlights the trimmed part there is a non visible match 3`] = `"</>...</><dim>sts__/watch-test.js"`;

exports[`highlights the trimmed part there is a non visible match 4`] = `"...watch-test.js"`;
exports[`highlights the trimmed part there is a non visible match 4`] = `"</>...</><dim>watch-test.js"`;

exports[`highlights the trimmed part there is a non visible match 5`] = `"...-test.js"`;
exports[`highlights the trimmed part there is a non visible match 5`] = `"</>...</><dim>-test.js"`;

exports[`highlights the trimmed part there is a non visible match 6`] = `"....js"`;
exports[`highlights the trimmed part there is a non visible match 6`] = `"</>...</><dim>.js"`;
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`trimAndFormatPath() does not trim anything 1`] = `"1234567890/1234567890/1234.js"`;
exports[`trimAndFormatPath() does not trim anything 1`] = `"<dim>1234567890/1234567890/<bold>1234.js"`;

exports[`trimAndFormatPath() split at the path.sep index 1`] = `".../1234.js"`;
exports[`trimAndFormatPath() split at the path.sep index 1`] = `"<dim>.../<bold>1234.js"`;

exports[`trimAndFormatPath() trims dirname (longer line width) 1`] = `"...890/1234567890/1234.js"`;
exports[`trimAndFormatPath() trims dirname (longer line width) 1`] = `"<dim>...890/1234567890/<bold>1234.js"`;

exports[`trimAndFormatPath() trims dirname 1`] = `"...234567890/1234.js"`;
exports[`trimAndFormatPath() trims dirname 1`] = `"<dim>...234567890/<bold>1234.js"`;

exports[`trimAndFormatPath() trims dirname and basename 1`] = `"...1234.js"`;
exports[`trimAndFormatPath() trims dirname and basename 1`] = `"<bold>...1234.js"`;

exports[`wrapAnsiString() returns the string unaltered if given a terminal width of zero 1`] = `"This string shouldn't cause you any trouble"`;

exports[`wrapAnsiString() returns the string unaltered if given a terminal width of zero 2`] = `"This string shouldn't cause you any trouble"`;

exports[`wrapAnsiString() wraps a long string containing ansi chars 1`] = `
"abcde red-
bold 12344
56bcd 123t
"abcde <red><bold>red-
bold</> 12344
56<dim>bcd 123t
tttttththt
hththththt
hththththt
hththththt
hthththtet
etetetette
tetetetete
tetetestnh
snthsnthss
tetete<bold>stnh
snthsnthss
ot"
`;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,58 +1,58 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Upgrade help logs a warning when \`scriptPreprocessor\` and/or \`preprocessorIgnorePatterns\` are used 1`] = `
"● Deprecation Warning:
"<bold><bold>●<bold> Deprecation Warning:

Option \\"preprocessorIgnorePatterns\\" was replaced by \\"transformIgnorePatterns\\", which support multiple preprocessors.
Option <bold>\\"preprocessorIgnorePatterns\\" was replaced by <bold>\\"transformIgnorePatterns\\", which support multiple preprocessors.

Jest now treats your current configuration as:
{
\\"transformIgnorePatterns\\": [\\"bar/baz\\", \\"qux/quux\\"]
<bold>\\"transformIgnorePatterns\\": <bold>[\\"bar/baz\\", \\"qux/quux\\"]
}

Please update your configuration.

Configuration Documentation:
<bold>Configuration Documentation:
https://facebook.github.io/jest/docs/configuration.html
"
</>"
`;

exports[`preset throws when preset not found 1`] = `
"● Validation Error:
"<red><bold><bold>● <bold>Validation Error:

Preset doesnt-exist not found.
Preset <bold>doesnt-exist not found.

Configuration Documentation:
<bold>Configuration Documentation:
https://facebook.github.io/jest/docs/configuration.html
"
</>"
`;

exports[`rootDir throws if the config is missing a rootDir property 1`] = `
"● Validation Error:
"<red><bold><bold>● <bold>Validation Error:

Configuration option rootDir must be specified.
Configuration option <bold>rootDir must be specified.

Configuration Documentation:
<bold>Configuration Documentation:
https://facebook.github.io/jest/docs/configuration.html
"
</>"
`;

exports[`testEnvironment throws on invalid environment names 1`] = `
"● Validation Error:
"<red><bold><bold>● <bold>Validation Error:

Test environment phantom cannot be found. Make sure the testEnvironment configuration option points to an existing node module.
Test environment <bold>phantom cannot be found. Make sure the <bold>testEnvironment configuration option points to an existing node module.

Configuration Documentation:
<bold>Configuration Documentation:
https://facebook.github.io/jest/docs/configuration.html
"
</>"
`;

exports[`testMatch throws if testRegex and testMatch are both specified 1`] = `
"● Validation Error:
"<red><bold><bold>● <bold>Validation Error:

Configuration options testMatch and testRegex cannot be used together.
Configuration options <bold>testMatch and <bold>testRegex cannot be used together.

Configuration Documentation:
<bold>Configuration Documentation:
https://facebook.github.io/jest/docs/configuration.html
"
</>"
`;
46 changes: 23 additions & 23 deletions packages/jest-diff/src/__tests__/__snapshots__/diff-test.js.snap
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`collapses big diffs to patch format 1`] = `
"- Expected
+ Received
"<green>- Expected</>
<red>+ Received</>

@@ -6,9 +6,9 @@
 4,
 5,
 6,
 7,
 8,
+ 10,
 9,
- 10,
 ],
 }"
@@ -6,9 +6,9 @@
</><dim> 4,
<dim> 5,
<dim> 6,
<dim> 7,
<dim> 8,
<red>+ 10,</>
<dim> 9,
<green>- 10,</>
<dim> ],
<dim> }"
`;

exports[`falls back to not call toJSON if objects look identical 1`] = `
"Compared values serialize to the same structure.
Printing internal object structure without calling \`toJSON\` instead.
"<dim>Compared values serialize to the same structure.
Printing internal object structure without calling \`toJSON\` instead.

- Expected
+ Received
<green>- Expected</>
<red>+ Received</>

  Object {
-  \\"line\\": 1,
+  \\"line\\": 2,
   \\"toJSON\\": [Function toJSON],
  }"
<dim> <dim>Object {
<green>-</> <green> \\"line\\": 1,</>
<red>+</> <red> \\"line\\": 2,</>
<dim> <dim> \\"toJSON\\": [Function toJSON],
<dim> <dim>}"
`;

exports[`prints a fallback message if two objects truly look identical 1`] = `"Compared values have no visual difference."`;
exports[`prints a fallback message if two objects truly look identical 1`] = `"<dim>Compared values have no visual difference."`;
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`matchers proxies matchers to jest-matchers 1`] = `
"expect(received).toBe(expected)
"<dim>expect(<red>received</><dim>).toBe(<green>expected</><dim>)

Expected value to be (using ===):
2
<green>2</>
Received:
1"
<red>1</>"
`;
Loading