Skip to content

Commit

Permalink
chore(project-config): switch to vitest (#9864)
Browse files Browse the repository at this point in the history
Switches our tests in `@redwoodjs/project-config` over to vitest.
  • Loading branch information
Josh-Walker-GM authored Jan 22, 2024
1 parent e17322b commit 74a9b0a
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 18 deletions.
1 change: 0 additions & 1 deletion packages/project-config/.babelrc.js

This file was deleted.

8 changes: 0 additions & 8 deletions packages/project-config/jest.config.js

This file was deleted.

8 changes: 4 additions & 4 deletions packages/project-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"build:types": "tsc --build --verbose",
"build:watch": "nodemon --watch src --ext \"js,ts,tsx\" --ignore dist --exec \"yarn build\"",
"prepublishOnly": "NODE_ENV=production yarn build",
"test": "jest src",
"test:watch": "run test --watch"
"test": "vitest run src",
"test:watch": "vitest watch src"
},
"dependencies": {
"@iarna/toml": "2.2.5",
Expand All @@ -31,9 +31,9 @@
},
"devDependencies": {
"esbuild": "0.19.9",
"jest": "29.7.0",
"rimraf": "5.0.5",
"typescript": "5.3.3"
"typescript": "5.3.3",
"vitest": "1.2.1"
},
"gitHead": "3905ed045508b861b495f8d5630d76c7a157d8f1"
}
2 changes: 2 additions & 0 deletions packages/project-config/src/__tests__/config.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import path from 'path'

import { describe, it, expect } from 'vitest'

import { getConfig, getRawConfig } from '../config'

describe('getRawConfig', () => {
Expand Down
10 changes: 6 additions & 4 deletions packages/project-config/src/__tests__/paths.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import path from 'path'

import { describe, beforeAll, afterAll, it, expect, test } from 'vitest'

import {
processPagesDir,
resolveFile,
Expand Down Expand Up @@ -226,7 +228,7 @@ describe('paths', () => {
})
})

describe('resolveFile', () => {
test('resolveFile', () => {
const p = resolveFile(path.join(FIXTURE_BASEDIR, 'web', 'src', 'App'))
expect(path.extname(p)).toEqual('.tsx')

Expand Down Expand Up @@ -547,7 +549,7 @@ describe('paths', () => {
})
})

describe('resolveFile', () => {
test('resolveFile', () => {
const p = resolveFile(path.join(FIXTURE_BASEDIR, 'web', 'src', 'App'))
expect(path.extname(p)).toEqual('.js')

Expand Down Expand Up @@ -826,7 +828,7 @@ describe('paths', () => {
})
})

describe('resolveFile', () => {
test('resolveFile', () => {
const p = resolveFile(path.join(FIXTURE_BASEDIR, 'web', 'src', 'index'))
expect(path.extname(p)).toEqual('.js')

Expand Down Expand Up @@ -1158,7 +1160,7 @@ describe('paths', () => {
})
})

describe('resolveFile', () => {
test('resolveFile', () => {
const p = resolveFile(path.join(FIXTURE_BASEDIR, 'web', 'src', 'Routes'))
expect(path.extname(p)).toEqual('.tsx')

Expand Down
12 changes: 12 additions & 0 deletions packages/project-config/vitest.config.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { defineConfig, configDefaults } from 'vitest/config'

export default defineConfig({
test: {
testTimeout: 15_000,
include: ['**/__tests__/**/*.[jt]s?(x)', '**/*.test.[jt]s?(x)'],
exclude: [...configDefaults.exclude, '**/fixtures', '**/dist'],
alias: {
'src/(.*)': '<rootDir>/src/$1',
}
},
})
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8648,10 +8648,10 @@ __metadata:
deepmerge: "npm:4.3.1"
esbuild: "npm:0.19.9"
fast-glob: "npm:3.3.2"
jest: "npm:29.7.0"
rimraf: "npm:5.0.5"
string-env-interpolation: "npm:1.0.1"
typescript: "npm:5.3.3"
vitest: "npm:1.2.1"
languageName: unknown
linkType: soft

Expand Down

0 comments on commit 74a9b0a

Please sign in to comment.