Skip to content

Commit

Permalink
feat: include sinon-chai
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Dec 4, 2021
1 parent 2f20237 commit d8f58f7
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"dependencies": {
"@jest/test-result": "^27.4.2",
"@types/chai": "^4.2.22",
"@types/sinon-chai": "^3.2.6",
"chai": "^4.3.4",
"fast-glob": "^3.2.7",
"find-up": "^6.2.0",
Expand All @@ -65,6 +66,7 @@
"ora": "^6.0.1",
"picocolors": "^1.0.0",
"sinon": "^12.0.1",
"sinon-chai": "^3.7.0",
"vite-node": "^0.1.10"
}
}
22 changes: 21 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const defaultIncludes = ['**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}']
export const defaultExcludes = ['**/node_modules/**', '**/dist/**']
9 changes: 7 additions & 2 deletions src/run.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import chai from 'chai'
import fg from 'fast-glob'
import SinonChai from 'sinon-chai'
import { clearContext, defaultSuite } from './suite'
import { context } from './context'
import { File, Options, Suite, Task, Reporter, RunnerContext } from './types'
import { afterEachHook, afterFileHook, afterAllHook, afterSuiteHook, beforeEachHook, beforeFileHook, beforeAllHook, beforeSuiteHook } from './hooks'
import { SnapshotPlugin } from './snapshot'
import { DefaultReporter } from './reporters/default'
import { defaultIncludes, defaultExcludes } from './constants'

export async function runTask(task: Task, ctx: RunnerContext) {
const { reporter } = ctx
Expand Down Expand Up @@ -82,17 +84,20 @@ export async function runFile(file: File, ctx: RunnerContext) {
export async function run(options: Options = {}) {
const { rootDir = process.cwd() } = options

// setup chai
chai.use(await SnapshotPlugin({
rootDir,
update: options.updateSnapshot,
}))
chai.use(SinonChai)

// collect files
const paths = await fg(
options.includes || ['**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
options.includes || defaultIncludes,
{
absolute: true,
cwd: options.rootDir,
ignore: options.excludes || ['**/node_modules/**', '**/dist/**'],
ignore: options.excludes || defaultExcludes,
},
)

Expand Down

0 comments on commit d8f58f7

Please sign in to comment.