Skip to content

Commit 4d25dc1

Browse files
committed
Fix linting errors
1 parent 70816db commit 4d25dc1

File tree

4 files changed

+37
-33
lines changed

4 files changed

+37
-33
lines changed
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { NewPlugin } from '@vitest/pretty-format'
22
import { getCurrentTest } from '@vitest/runner'
3+
import { expect, test } from 'vitest'
34

45
const AlwaysFailingSnapshotSerializer: NewPlugin = {
56
test: obj => obj && obj.forceFail === true,
@@ -11,7 +12,7 @@ expect.addSnapshotSerializer(AlwaysFailingSnapshotSerializer)
1112

1213
test('expect.soft tracks an error for toMatchSnapshot', () => {
1314
expect.soft({ forceFail: true }).toMatchSnapshot()
14-
15+
1516
expect(getCurrentTest()?.result?.errors).toHaveLength(1)
1617
expect(getCurrentTest()?.result?.state).toBe('fail')
1718
passTestIfInFailedStateWithErrors()
@@ -20,47 +21,47 @@ test('expect.soft tracks an error for toMatchSnapshot', () => {
2021
test('expect.soft tracks multiple errors for toMatchSnapshot', () => {
2122
expect.soft({ forceFail: true }).toMatchSnapshot()
2223
expect.soft({ forceFail: true }).toMatchSnapshot()
23-
24+
2425
expect(getCurrentTest()?.result?.errors).toHaveLength(2)
2526
expect(getCurrentTest()?.result?.state).toBe('fail')
2627
passTestIfInFailedStateWithErrors()
2728
})
2829

2930
test('expect.soft tracks errors across successes for toMatchSnapshot', () => {
30-
expect.soft('I have a matching snapshot').toMatchSnapshot();
31+
expect.soft('I have a matching snapshot').toMatchSnapshot()
3132
expect.soft({ forceFail: true }).toMatchSnapshot()
32-
expect.soft('I also have a matching snapshot').toMatchSnapshot();
33+
expect.soft('I also have a matching snapshot').toMatchSnapshot()
3334
expect.soft({ forceFail: true }).toMatchSnapshot()
34-
expect.soft('Yet another matching snapshot').toMatchSnapshot();
35-
35+
expect.soft('Yet another matching snapshot').toMatchSnapshot()
36+
3637
expect(getCurrentTest()?.result?.errors).toHaveLength(2)
3738
expect(getCurrentTest()?.result?.state).toBe('fail')
3839
passTestIfInFailedStateWithErrors()
3940
})
4041

4142
test('expect.soft tracks errors for matchSnapshot', () => {
4243
expect.soft({ forceFail: true }).matchSnapshot()
43-
expect.soft('I also have a matching snapshot').toMatchSnapshot();
44+
expect.soft('I also have a matching snapshot').toMatchSnapshot()
4445
expect.soft({ forceFail: true }).matchSnapshot()
45-
46+
4647
expect(getCurrentTest()?.result?.errors).toHaveLength(2)
4748
expect(getCurrentTest()?.result?.state).toBe('fail')
4849
passTestIfInFailedStateWithErrors()
4950
})
5051

51-
test('expect.soft tracks errors for toMatchFileSnapshot', async() => {
52+
test('expect.soft tracks errors for toMatchFileSnapshot', async () => {
5253
await expect.soft({ forceFail: true }).toMatchFileSnapshot('fake-path/to-non-existent/file')
53-
expect.soft('Another matching snapshot').toMatchSnapshot();
54+
expect.soft('Another matching snapshot').toMatchSnapshot()
5455
await expect.soft({ forceFail: true }).toMatchFileSnapshot('fake-path/to-non-existent/file')
55-
56+
5657
expect(getCurrentTest()?.result?.errors).toHaveLength(2)
5758
expect(getCurrentTest()?.result?.state).toBe('fail')
5859
passTestIfInFailedStateWithErrors()
5960
})
6061

61-
test('expect.soft tracks errors for toThrowErrorMatchingSnapshot', async() => {
62+
test('expect.soft tracks errors for toThrowErrorMatchingSnapshot', async () => {
6263
expect.soft({ forceFail: true }).toThrowErrorMatchingSnapshot()
63-
expect.soft('Yet another matching snapshot').toMatchSnapshot();
64+
expect.soft('Yet another matching snapshot').toMatchSnapshot()
6465
expect.soft({ forceFail: true }).toThrowErrorMatchingSnapshot()
6566

6667
expect(getCurrentTest()?.result?.errors).toHaveLength(2)
@@ -70,9 +71,8 @@ test('expect.soft tracks errors for toThrowErrorMatchingSnapshot', async() => {
7071

7172
function passTestIfInFailedStateWithErrors() {
7273
const result = getCurrentTest()!.result!
73-
74+
7475
if (result.errors && result.state === 'fail') {
75-
result.state = 'pass'
76+
result.state = 'pass'
7677
}
7778
}
78-

test/snapshots/test-update/soft-inline.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { expect, test } from 'vitest'
2+
13
test('expect.soft fails if run with toMatchInlineSnapshot', () => {
24
let exceptionThrown = false
35
try {
Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { expect, test } from 'vitest'
12
import type { NewPlugin } from '@vitest/pretty-format'
23
import { getCurrentTest } from '@vitest/runner'
34

@@ -11,7 +12,7 @@ expect.addSnapshotSerializer(AlwaysFailingSnapshotSerializer)
1112

1213
test('expect.soft tracks an error for toMatchSnapshot', () => {
1314
expect.soft({ forceFail: true }).toMatchSnapshot()
14-
15+
1516
expect(getCurrentTest()?.result?.errors).toHaveLength(1)
1617
expect(getCurrentTest()?.result?.state).toBe('fail')
1718
passTestIfInFailedStateWithErrors()
@@ -20,47 +21,47 @@ test('expect.soft tracks an error for toMatchSnapshot', () => {
2021
test('expect.soft tracks multiple errors for toMatchSnapshot', () => {
2122
expect.soft({ forceFail: true }).toMatchSnapshot()
2223
expect.soft({ forceFail: true }).toMatchSnapshot()
23-
24+
2425
expect(getCurrentTest()?.result?.errors).toHaveLength(2)
2526
expect(getCurrentTest()?.result?.state).toBe('fail')
2627
passTestIfInFailedStateWithErrors()
2728
})
2829

2930
test('expect.soft tracks errors across successes for toMatchSnapshot', () => {
30-
expect.soft('I have a matching snapshot').toMatchSnapshot();
31+
expect.soft('I have a matching snapshot').toMatchSnapshot()
3132
expect.soft({ forceFail: true }).toMatchSnapshot()
32-
expect.soft('I also have a matching snapshot').toMatchSnapshot();
33+
expect.soft('I also have a matching snapshot').toMatchSnapshot()
3334
expect.soft({ forceFail: true }).toMatchSnapshot()
34-
expect.soft('Yet another matching snapshot').toMatchSnapshot();
35-
35+
expect.soft('Yet another matching snapshot').toMatchSnapshot()
36+
3637
expect(getCurrentTest()?.result?.errors).toHaveLength(2)
3738
expect(getCurrentTest()?.result?.state).toBe('fail')
3839
passTestIfInFailedStateWithErrors()
3940
})
4041

4142
test('expect.soft tracks errors for matchSnapshot', () => {
4243
expect.soft({ forceFail: true }).matchSnapshot()
43-
expect.soft('I also have a matching snapshot').toMatchSnapshot();
44+
expect.soft('I also have a matching snapshot').toMatchSnapshot()
4445
expect.soft({ forceFail: true }).matchSnapshot()
45-
46+
4647
expect(getCurrentTest()?.result?.errors).toHaveLength(2)
4748
expect(getCurrentTest()?.result?.state).toBe('fail')
4849
passTestIfInFailedStateWithErrors()
4950
})
5051

51-
test('expect.soft tracks errors for toMatchFileSnapshot', async() => {
52+
test('expect.soft tracks errors for toMatchFileSnapshot', async () => {
5253
await expect.soft({ forceFail: true }).toMatchFileSnapshot('fake-path/to-non-existent/file')
53-
expect.soft('Another matching snapshot').toMatchSnapshot();
54+
expect.soft('Another matching snapshot').toMatchSnapshot()
5455
await expect.soft({ forceFail: true }).toMatchFileSnapshot('fake-path/to-non-existent/file')
55-
56+
5657
expect(getCurrentTest()?.result?.errors).toHaveLength(2)
5758
expect(getCurrentTest()?.result?.state).toBe('fail')
5859
passTestIfInFailedStateWithErrors()
5960
})
6061

61-
test('expect.soft tracks errors for toThrowErrorMatchingSnapshot', async() => {
62+
test('expect.soft tracks errors for toThrowErrorMatchingSnapshot', async () => {
6263
expect.soft({ forceFail: true }).toThrowErrorMatchingSnapshot()
63-
expect.soft('Yet another matching snapshot').toMatchSnapshot();
64+
expect.soft('Yet another matching snapshot').toMatchSnapshot()
6465
expect.soft({ forceFail: true }).toThrowErrorMatchingSnapshot()
6566

6667
expect(getCurrentTest()?.result?.errors).toHaveLength(2)
@@ -70,9 +71,8 @@ test('expect.soft tracks errors for toThrowErrorMatchingSnapshot', async() => {
7071

7172
function passTestIfInFailedStateWithErrors() {
7273
const result = getCurrentTest()!.result!
73-
74+
7475
if (result.errors && result.state === 'fail') {
75-
result.state = 'pass'
76+
result.state = 'pass'
7677
}
77-
}
78-
78+
}

test/snapshots/test/fixtures/test-update/soft-inline.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { expect, test } from 'vitest'
2+
13
test('expect.soft fails if run with toMatchInlineSnapshot', () => {
24
let exceptionThrown = false
35
try {

0 commit comments

Comments
 (0)