Skip to content

Commit 51ea536

Browse files
nickservgnapse
andauthored
chore: upgrade to Jest 27 (#384)
* chore: upgrade to Jest 27 * fix: ESLint config Co-authored-by: Ernesto García <gnapse@gmail.com>
1 parent 60832f6 commit 51ea536

8 files changed

+49
-49
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@
4545
"jest-environment-jsdom-sixteen": "^1.0.3",
4646
"jest-watch-select-projects": "^2.0.0",
4747
"jsdom": "^16.2.1",
48-
"kcd-scripts": "^5.6.0",
48+
"kcd-scripts": "^11.1.0",
4949
"pretty-format": "^25.1.0"
5050
},
5151
"eslintConfig": {
5252
"extends": "./node_modules/kcd-scripts/eslint.js",
5353
"rules": {
54-
"babel/no-invalid-this": "off"
54+
"@babel/no-invalid-this": "off"
5555
},
5656
"overrides": [
5757
{

src/__tests__/to-contain-html.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,11 @@ describe('.toContainHTML', () => {
102102
}
103103

104104
expect(errorMessage).toMatchInlineSnapshot(`
105-
"<dim>expect(</><red>element</><dim>).toContainHTML()</>
106-
Expected:
107-
<green><div> non-existant element </div></>
108-
Received:
109-
<red><span data-testid=\\"child\\" /></>"
110-
`)
105+
<dim>expect(</><red>element</><dim>).toContainHTML()</>
106+
Expected:
107+
<green><div> non-existant element </div></>
108+
Received:
109+
<red><span data-testid="child" /></>
110+
`)
111111
})
112112
})

src/__tests__/to-have-display-value.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ test('it should throw if element is not valid', () => {
129129
}
130130

131131
expect(errorMessage).toMatchInlineSnapshot(
132-
`".toHaveDisplayValue() currently supports only input, textarea or select elements, try with another matcher instead."`,
132+
`.toHaveDisplayValue() currently supports only input, textarea or select elements, try with another matcher instead.`,
133133
)
134134

135135
try {
@@ -139,7 +139,7 @@ test('it should throw if element is not valid', () => {
139139
}
140140

141141
expect(errorMessage).toMatchInlineSnapshot(
142-
`".toHaveDisplayValue() currently does not support input[type=\\"radio\\"], try with another matcher instead."`,
142+
`.toHaveDisplayValue() currently does not support input[type="radio"], try with another matcher instead.`,
143143
)
144144

145145
try {
@@ -149,7 +149,7 @@ test('it should throw if element is not valid', () => {
149149
}
150150

151151
expect(errorMessage).toMatchInlineSnapshot(
152-
`".toHaveDisplayValue() currently does not support input[type=\\"checkbox\\"], try with another matcher instead."`,
152+
`.toHaveDisplayValue() currently does not support input[type="checkbox"], try with another matcher instead.`,
153153
)
154154
})
155155

src/__tests__/to-have-value.js

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,13 @@ describe('.toHaveValue', () => {
115115
}
116116

117117
expect(errorMessage).toMatchInlineSnapshot(`
118-
"<dim>expect(</><red>element</><dim>).toHaveValue(</><green>something else</><dim>)</>
118+
<dim>expect(</><red>element</><dim>).toHaveValue(</><green>something else</><dim>)</>
119119
120-
Expected the element to have value:
121-
<green> something else</>
122-
Received:
123-
<red> foo</>"
124-
`)
120+
Expected the element to have value:
121+
<green> something else</>
122+
Received:
123+
<red> foo</>
124+
`)
125125
})
126126

127127
test('throws with type information when the expected text input value has loose equality with received value', () => {
@@ -135,13 +135,13 @@ describe('.toHaveValue', () => {
135135
}
136136

137137
expect(errorMessage).toMatchInlineSnapshot(`
138-
"<dim>expect(</><red>element</><dim>).toHaveValue(</><green>8</><dim>)</>
138+
<dim>expect(</><red>element</><dim>).toHaveValue(</><green>8</><dim>)</>
139139
140-
Expected the element to have value:
141-
<green> 8 (number)</>
142-
Received:
143-
<red> 8 (string)</>"
144-
`)
140+
Expected the element to have value:
141+
<green> 8 (number)</>
142+
Received:
143+
<red> 8 (string)</>
144+
`)
145145
})
146146

147147
test('throws when using not but the expected input value does match', () => {
@@ -155,13 +155,13 @@ describe('.toHaveValue', () => {
155155
errorMessage = error.message
156156
}
157157
expect(errorMessage).toMatchInlineSnapshot(`
158-
"<dim>expect(</><red>element</><dim>).not.toHaveValue(</><green>foo</><dim>)</>
158+
<dim>expect(</><red>element</><dim>).not.toHaveValue(</><green>foo</><dim>)</>
159159
160-
Expected the element not to have value:
161-
<green> foo</>
162-
Received:
163-
<red> foo</>"
164-
`)
160+
Expected the element not to have value:
161+
<green> foo</>
162+
Received:
163+
<red> foo</>
164+
`)
165165
})
166166

167167
test('throws when the form has no a value but a value is expected', () => {
@@ -175,13 +175,13 @@ describe('.toHaveValue', () => {
175175
errorMessage = error.message
176176
}
177177
expect(errorMessage).toMatchInlineSnapshot(`
178-
"<dim>expect(</><red>element</><dim>).toHaveValue(</><green>expected</><dim>)</>
178+
<dim>expect(</><red>element</><dim>).toHaveValue(</><green>expected</><dim>)</>
179179
180-
Expected the element to have value:
181-
<green> (any)</>
182-
Received:
183-
"
184-
`)
180+
Expected the element to have value:
181+
<green> (any)</>
182+
Received:
183+
184+
`)
185185
})
186186

187187
test('throws when the form has a value but none is expected', () => {
@@ -195,12 +195,12 @@ describe('.toHaveValue', () => {
195195
errorMessage = error.message
196196
}
197197
expect(errorMessage).toMatchInlineSnapshot(`
198-
"<dim>expect(</><red>element</><dim>).not.toHaveValue(</><green>expected</><dim>)</>
198+
<dim>expect(</><red>element</><dim>).not.toHaveValue(</><green>expected</><dim>)</>
199199
200-
Expected the element not to have value:
201-
<green> (any)</>
202-
Received:
203-
<red> foo</>"
204-
`)
200+
Expected the element not to have value:
201+
<green> (any)</>
202+
Received:
203+
<red> foo</>
204+
`)
205205
})
206206
})

src/to-be-in-the-document.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export function toBeInTheDocument(element) {
2929
'',
3030
),
3131
'',
32-
// eslint-disable-next-line babel/new-cap
32+
// eslint-disable-next-line @babel/new-cap
3333
this.utils.RECEIVED_COLOR(this.isNot ? errorFound() : errorNotFound()),
3434
].join('\n')
3535
},

src/to-contain-element.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export function toContainElement(container, element) {
1717
'element',
1818
),
1919
'',
20-
// eslint-disable-next-line babel/new-cap
20+
// eslint-disable-next-line @babel/new-cap
2121
this.utils.RECEIVED_COLOR(`${this.utils.stringify(
2222
container.cloneNode(false),
2323
)} ${

src/to-contain-html.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export function toContainHTML(container, htmlText) {
2323
'',
2424
),
2525
'Expected:',
26-
// eslint-disable-next-line babel/new-cap
26+
// eslint-disable-next-line @babel/new-cap
2727
` ${this.utils.EXPECTED_COLOR(htmlText)}`,
2828
'Received:',
2929
` ${this.utils.printReceived(container.cloneNode(true))}`,

src/utils.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class GenericTypeError extends Error {
2828
'',
2929
),
3030
'',
31-
// eslint-disable-next-line babel/new-cap
31+
// eslint-disable-next-line @babel/new-cap
3232
`${context.utils.RECEIVED_COLOR(
3333
'received',
3434
)} value must ${expectedString}.`,
@@ -91,9 +91,9 @@ class InvalidCSSError extends Error {
9191
this.message = [
9292
received.message,
9393
'',
94-
// eslint-disable-next-line babel/new-cap
94+
// eslint-disable-next-line @babel/new-cap
9595
context.utils.RECEIVED_COLOR(`Failing css:`),
96-
// eslint-disable-next-line babel/new-cap
96+
// eslint-disable-next-line @babel/new-cap
9797
context.utils.RECEIVED_COLOR(`${received.css}`),
9898
].join('\n')
9999
}
@@ -137,11 +137,11 @@ function getMessage(
137137
) {
138138
return [
139139
`${matcher}\n`,
140-
// eslint-disable-next-line babel/new-cap
140+
// eslint-disable-next-line @babel/new-cap
141141
`${expectedLabel}:\n${context.utils.EXPECTED_COLOR(
142142
redent(display(context, expectedValue), 2),
143143
)}`,
144-
// eslint-disable-next-line babel/new-cap
144+
// eslint-disable-next-line @babel/new-cap
145145
`${receivedLabel}:\n${context.utils.RECEIVED_COLOR(
146146
redent(display(context, receivedValue), 2),
147147
)}`,

0 commit comments

Comments
 (0)