Skip to content

Instantly share code, notes, and snippets.

@orgads
Created November 3, 2021 13:12
Show Gist options
  • Save orgads/c2a12ec176f3c6104f3f79d3ff7197bf to your computer and use it in GitHub Desktop.
Save orgads/c2a12ec176f3c6104f3f79d3ff7197bf to your computer and use it in GitHub Desktop.
```
~/better-ajv-errors$ npm test
> better-ajv-errors@0.8.0 test
> jest
FAIL src/validation-errors/__tests__/required.js
● Required › prints correctly for missing required prop
expect(received).toMatchSnapshot()
Snapshot name: `Required prints correctly for missing required prop 1`
- Snapshot
+ Received
Array [
"REQUIRED should have required property 'id'
",
- " 1 | {
- > 2 | "nested": {}
- | ^ ☹️ id is missing here!
- 3 | }",
+ " 1 | {
+ > 2 | "nested": {}
+ | ^ ☹️ id is missing here!
+ 3 | }",
]
20 | );
21 |
> 22 | expect(error.print()).toMatchSnapshot();
| ^
23 | });
24 | });
25 |
at Object.<anonymous> (src/validation-errors/__tests__/required.js:22:27)
› 1 snapshot failed.
FAIL src/validation-errors/__tests__/enum.js
● Enum › when value is an object › prints correctly for enum prop
expect(received).toMatchSnapshot()
Snapshot name: `Enum when value is an object prints correctly for enum prop 1`
- Snapshot
+ Received
Array [
"ENUM should be equal to one of the allowed values",
"(foo, bar)
",
- " 1 | {
- > 2 | "id": "baz"
- | ^^^^^ 👈🏽 Did you mean bar here?
- 3 | }",
+ " 1 | {
+ > 2 | "id": "baz"
+ | ^^^^^ 👈🏽 Did you mean bar here?
+ 3 | }",
]
24 | );
25 |
> 26 | expect(error.print()).toMatchSnapshot();
| ^
27 | });
28 |
29 | it('prints correctly for no levenshtein match', () => {
at Object.<anonymous> (src/validation-errors/__tests__/enum.js:26:29)
● Enum › when value is an object › prints correctly for no levenshtein match
expect(received).toMatchSnapshot()
Snapshot name: `Enum when value is an object prints correctly for no levenshtein match 1`
- Snapshot
+ Received
Array [
"ENUM should be equal to one of the allowed values",
"(one, two)
",
- " 1 | {
- > 2 | "id": "baz"
- | ^^^^^ 👈🏽 Unexpected value, should be equal to one of the allowed values
- 3 | }",
+ " 1 | {
+ > 2 | "id": "baz"
+ | ^^^^^ 👈🏽 Unexpected value, should be equal to one of the allowed values
+ 3 | }",
]
39 | );
40 |
> 41 | expect(error.print()).toMatchSnapshot();
| ^
42 | });
43 |
44 | it('prints correctly for empty value', () => {
at Object.<anonymous> (src/validation-errors/__tests__/enum.js:41:29)
● Enum › when value is an object › prints correctly for empty value
expect(received).toMatchSnapshot()
Snapshot name: `Enum when value is an object prints correctly for empty value 1`
- Snapshot
+ Received
Array [
"ENUM should be equal to one of the allowed values",
"(foo, bar)
",
- " 1 | {
- > 2 | "id": "baz"
- | ^^^^^ 👈🏽 Did you mean bar here?
- 3 | }",
+ " 1 | {
+ > 2 | "id": "baz"
+ | ^^^^^ 👈🏽 Did you mean bar here?
+ 3 | }",
]
54 | );
55 |
> 56 | expect(error.print(schema, { id: '' })).toMatchSnapshot();
| ^
57 | });
58 | });
59 |
at Object.<anonymous> (src/validation-errors/__tests__/enum.js:56:47)
● Enum › when value is a primitive › prints correctly for enum prop
expect(received).toMatchSnapshot()
Snapshot name: `Enum when value is a primitive prints correctly for enum prop 1`
- Snapshot
+ Received
Array [
"ENUM should be equal to one of the allowed values",
"(foo, bar)
",
- "> 1 | "baz"
- | ^^^^^ 👈🏽 Did you mean bar here?",
+ "> 1 | "baz"
+ | ^^^^^ 👈🏽 Did you mean bar here?",
]
80 | );
81 |
> 82 | expect(error.print()).toMatchSnapshot();
| ^
83 | });
84 |
85 | it('prints correctly for no levenshtein match', () => {
at Object.<anonymous> (src/validation-errors/__tests__/enum.js:82:29)
● Enum › when value is a primitive › prints correctly for no levenshtein match
expect(received).toMatchSnapshot()
Snapshot name: `Enum when value is a primitive prints correctly for no levenshtein match 1`
- Snapshot
+ Received
Array [
"ENUM should be equal to one of the allowed values",
"(one, two)
",
- "> 1 | "baz"
- | ^^^^^ 👈🏽 Unexpected value, should be equal to one of the allowed values",
+ "> 1 | "baz"
+ | ^^^^^ 👈🏽 Unexpected value, should be equal to one of the allowed values",
]
97 | );
98 |
> 99 | expect(error.print()).toMatchSnapshot();
| ^
100 | });
101 |
102 | it('prints correctly for empty value', () => {
at Object.<anonymous> (src/validation-errors/__tests__/enum.js:99:29)
● Enum › when value is a primitive › prints correctly for empty value
expect(received).toMatchSnapshot()
Snapshot name: `Enum when value is a primitive prints correctly for empty value 1`
- Snapshot
+ Received
Array [
"ENUM should be equal to one of the allowed values",
"(foo, bar)
",
- "> 1 | "baz"
- | ^^^^^ 👈🏽 Did you mean bar here?",
+ "> 1 | "baz"
+ | ^^^^^ 👈🏽 Did you mean bar here?",
]
114 | );
115 |
> 116 | expect(error.print(schema, '')).toMatchSnapshot();
| ^
117 | });
118 | });
119 | });
at Object.<anonymous> (src/validation-errors/__tests__/enum.js:116:39)
› 6 snapshots failed.
FAIL src/__tests__/index.js
● Main › should output error with reconstructed codeframe
expect(received).toMatchSnapshot()
Snapshot name: `Main should output error with reconstructed codeframe 1`
- Snapshot
+ Received
ENUM must be equal to one of the allowed values
(paragraph, codeBlock, blockquote)
- 4 | "content": [
+ 4 | "content": [
- 5 | {
+ 5 | {
- > 6 | "type": "paragarph"
+ > 6 | "type": "paragarph"
- | ^^^^^^^^^^^ 👈🏽 Did you mean paragraph here?
+ | ^^^^^^^^^^^ 👈🏽 Did you mean paragraph here?
- 7 | }
+ 7 | }
- 8 | ]
+ 8 | ]
- 9 | }
+ 9 | }
15 | indent: 2,
16 | });
> 17 | expect(res).toMatchSnapshot();
| ^
18 | });
19 |
20 | it('should output error with codeframe', async () => {
at Object.<anonymous> (src/__tests__/index.js:17:17)
● Main › should output error with codeframe
expect(received).toMatchSnapshot()
Snapshot name: `Main should output error with codeframe 1`
- Snapshot
+ Received
ENUM must be equal to one of the allowed values
(paragraph, codeBlock, blockquote)
- 2 | "type": "doc",
+ 2 | "type": "doc",
- 3 | "version": 1,
+ 3 | "version": 1,
- > 4 | "content": [{ "type": "paragarph" }]
+ > 4 | "content": [{ "type": "paragarph" }]
- | ^^^^^^^^^^^ 👈🏽 Did you mean paragraph here?
+ | ^^^^^^^^^^^ 👈🏽 Did you mean paragraph here?
- 5 | }
+ 5 | }
- 6 |
+ 6 |
29 | json,
30 | });
> 31 | expect(res).toMatchSnapshot();
| ^
32 | });
33 | });
34 |
at Object.<anonymous> (src/__tests__/index.js:31:17)
› 2 snapshots failed.
PASS src/json/__tests__/index.js
PASS src/__tests__/helpers/filter-redundant-errors.js
PASS src/validation-errors/__tests__/main.js
PASS src/__tests__/helpers/make-tree.js
PASS src/__tests__/helpers/create-error-instances.js
Snapshot Summary
› 9 snapshots failed from 3 test suites. Inspect your code changes or run `npm test -- -u` to update them.
Test Suites: 3 failed, 5 passed, 8 total
Tests: 9 failed, 24 passed, 33 total
Snapshots: 9 failed, 28 passed, 37 total
Time: 2.7s, estimated 4s
Ran all test suites.
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment