Skip to content

Commit

Permalink
add force-rerun tests and vitest config
Browse files Browse the repository at this point in the history
  • Loading branch information
elliotwestlake committed Jul 4, 2022
1 parent 363d926 commit 8dba057
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/related/force-rerun.vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineConfig } from 'vitest/config'

export default defineConfig({
test: {
include: ['tests/related.test.ts'],
forceRerunTriggers: ['**/rerun.temp/**'],
},
})
24 changes: 24 additions & 0 deletions test/related/tests/force-rerun.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { unlink, writeFile } from 'fs'
import { beforeEach, describe, expect, it } from 'vitest'
import { execa } from 'execa'

const run = async () => await execa('vitest', ['run', '--changed', '--config', 'force-rerun.vitest.config.ts'])

const fileName = 'rerun.temp'

describe('forceRerunTrigger', () => {
beforeEach(async () => {
unlink(fileName, () => {})
})

it('should run the whole test suite if file exists', async () => {
writeFile(fileName, '', error => console.error(error))
const { stdout } = await run()
expect(stdout).toContain('1 passed')
})

it('should run no tests if file does not exist', async () => {
const { stdout } = await run()
expect(stdout).toContain('No test files found, exiting with code 0')
})
})

0 comments on commit 8dba057

Please sign in to comment.