Skip to content

Commit

Permalink
test: test retry
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Oct 31, 2024
1 parent fd8d60c commit 1cdaa67
Show file tree
Hide file tree
Showing 4 changed files with 153 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/snapshots/test-update/__snapshots__/retry.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`file repeats 1`] = `"foo"`;

exports[`file repeats many 1`] = `"foo"`;

exports[`file repeats many 2`] = `"bar"`;

exports[`file retry 1`] = `"foo"`;

exports[`file retry many 1`] = `"foo"`;

exports[`file retry many 2`] = `"bar"`;

exports[`file retry partial 1`] = `"foo"`;

exports[`file retry partial 2`] = `"bar"`;
44 changes: 44 additions & 0 deletions test/snapshots/test-update/retry.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { expect, test } from 'vitest'

test('inline repeats', { repeats: 1 }, () => {
expect('foo').toMatchInlineSnapshot(`"foo"`)
})

test('inline retry', { retry: 1 }, (ctx) => {
expect('foo').toMatchInlineSnapshot(`"foo"`)
if (ctx.task.result?.retryCount === 0) {
throw new Error('boom')
}
})

test('file repeats', { repeats: 1 }, () => {
expect('foo').toMatchSnapshot()
})

test('file retry', { retry: 1 }, (ctx) => {
expect('foo').toMatchSnapshot()
if (ctx.task.result?.retryCount === 0) {
throw new Error('boom')
}
})

test('file repeats many', { repeats: 1 }, () => {
expect('foo').toMatchSnapshot()
expect('bar').toMatchSnapshot()
})

test('file retry many', { retry: 1 }, (ctx) => {
expect('foo').toMatchSnapshot()
expect('bar').toMatchSnapshot()
if (ctx.task.result?.retryCount === 0) {
throw new Error('boom')
}
})

test('file retry partial', { retry: 1 }, (ctx) => {
expect('foo').toMatchSnapshot()
if (ctx.task.result?.retryCount === 0) {
throw new Error('boom')
}
expect('bar').toMatchSnapshot()
})
48 changes: 48 additions & 0 deletions test/snapshots/test/__snapshots__/test-update.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,54 @@ it.concurrent('3rd', ({ expect }) => {
"
`;
exports[`retry.test.ts 1`] = `
"import { expect, test } from 'vitest'
test('inline repeats', { repeats: 1 }, () => {
expect('foo').toMatchInlineSnapshot(\`"foo"\`)
})
test('inline retry', { retry: 1 }, (ctx) => {
expect('foo').toMatchInlineSnapshot(\`"foo"\`)
if (ctx.task.result?.retryCount === 0) {
throw new Error('boom')
}
})
test('file repeats', { repeats: 1 }, () => {
expect('foo').toMatchSnapshot()
})
test('file retry', { retry: 1 }, (ctx) => {
expect('foo').toMatchSnapshot()
if (ctx.task.result?.retryCount === 0) {
throw new Error('boom')
}
})
test('file repeats many', { repeats: 1 }, () => {
expect('foo').toMatchSnapshot()
expect('bar').toMatchSnapshot()
})
test('file retry many', { retry: 1 }, (ctx) => {
expect('foo').toMatchSnapshot()
expect('bar').toMatchSnapshot()
if (ctx.task.result?.retryCount === 0) {
throw new Error('boom')
}
})
test('file retry partial', { retry: 1 }, (ctx) => {
expect('foo').toMatchSnapshot()
if (ctx.task.result?.retryCount === 0) {
throw new Error('boom')
}
expect('bar').toMatchSnapshot()
})
"
`;
exports[`same-title-file.test.js 1`] = `
"import { expect, test } from 'vitest'
Expand Down
44 changes: 44 additions & 0 deletions test/snapshots/test/fixtures/test-update/retry.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { expect, test } from 'vitest'

test('inline repeats', { repeats: 1 }, () => {
expect('foo').toMatchInlineSnapshot()
})

test('inline retry', { retry: 1 }, (ctx) => {
expect('foo').toMatchInlineSnapshot()
if (ctx.task.result?.retryCount === 0) {
throw new Error('boom')
}
})

test('file repeats', { repeats: 1 }, () => {
expect('foo').toMatchSnapshot()
})

test('file retry', { retry: 1 }, (ctx) => {
expect('foo').toMatchSnapshot()
if (ctx.task.result?.retryCount === 0) {
throw new Error('boom')
}
})

test('file repeats many', { repeats: 1 }, () => {
expect('foo').toMatchSnapshot()
expect('bar').toMatchSnapshot()
})

test('file retry many', { retry: 1 }, (ctx) => {
expect('foo').toMatchSnapshot()
expect('bar').toMatchSnapshot()
if (ctx.task.result?.retryCount === 0) {
throw new Error('boom')
}
})

test('file retry partial', { retry: 1 }, (ctx) => {
expect('foo').toMatchSnapshot()
if (ctx.task.result?.retryCount === 0) {
throw new Error('boom')
}
expect('bar').toMatchSnapshot()
})

0 comments on commit 1cdaa67

Please sign in to comment.