Skip to content

Commit

Permalink
address changes and add peerdep to jest-cli
Browse files Browse the repository at this point in the history
  • Loading branch information
serena97 committed Jan 14, 2022
1 parent aa7967d commit de3f676
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
5 changes: 3 additions & 2 deletions core/sandbox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@
"@dotcom-tool-kit/lint-staged": "file:../../plugins/lint-staged",
"@dotcom-tool-kit/lint-staged-npm": "file:../../plugins/lint-staged-npm",
"@dotcom-tool-kit/mocha": "file:../../plugins/mocha",
"@dotcom-tool-kit/jest": "file:../../plugins/jest",
"@dotcom-tool-kit/n-test": "file:../../plugins/n-test",
"@dotcom-tool-kit/npm": "file:../../plugins/npm",
"@dotcom-tool-kit/prettier": "file:../../plugins/prettier",
"@dotcom-tool-kit/upload-assets-to-s3": "file:../../plugins/upload-assets-to-s3",
"dotcom-tool-kit": "file:../cli"
"dotcom-tool-kit": "file:../cli",
"jest-cli": "^27.4.7"
},
"volta": {
"extends": "../../package.json"
Expand All @@ -34,7 +36,6 @@
"@dotcom-tool-kit/node": "file:../../plugins/node"
},
"husky": {
"pre-commit": "dotcom-tool-kit git:precommit",
"hooks": {
"pre-commit": "dotcom-tool-kit git:precommit"
}
Expand Down
1 change: 1 addition & 0 deletions lib/types/src/schema/jest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { SchemaOutput } from '../schema'
export const JestSchema = {
configPath: 'string?'
} as const
export type JestMode = "ci" | "local"
export type JestOptions = SchemaOutput<typeof JestSchema>

export const Schema = JestSchema
6 changes: 4 additions & 2 deletions plugins/jest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
"author": "FT.com Platforms Team <platforms-team.customer-products@ft.com>",
"license": "ISC",
"dependencies": {
"@dotcom-tool-kit/types": "file:../../lib/types",
"jest-cli": "^27.4.7"
"@dotcom-tool-kit/types": "file:../../lib/types"
},
"peerDependencies": {
"jest-cli": "27.x"
},
"repository": {
"type": "git",
Expand Down
8 changes: 4 additions & 4 deletions plugins/jest/src/run-jest.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { fork } from 'child_process'
import type { JestOptions } from '@dotcom-tool-kit/types/lib/schema/jest'

import type { JestOptions, JestMode } from '@dotcom-tool-kit/types/lib/schema/jest'
import { ToolKitError } from '@dotcom-tool-kit/error'
const jestCLIPath = require.resolve('jest-cli/bin/jest')

export default function runJest(mode: string, options: JestOptions) : Promise<void> {
export default function runJest(mode: JestMode, options: JestOptions) : Promise<void> {
return new Promise((resolve, reject) => {
const config = [
mode === 'ci' ? '--ci' : '',
Expand All @@ -15,7 +15,7 @@ export default function runJest(mode: string, options: JestOptions) : Promise<vo
if (code === 0) {
resolve()
} else {
reject(new Error(`Jest returned an error`))
reject(new ToolKitError(`Jest returned an error`))
}
})
})
Expand Down
2 changes: 1 addition & 1 deletion plugins/jest/tests/jest-plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import EventEmitter from 'events'

jest.mock('child_process', () => ({
fork: jest.fn(() => {
// return a fake emitter that immediately sends an "exit" event, so the webpack task resolves
// return a fake emitter that immediately sends an "exit" event, so the jest task resolves
const emitter = new EventEmitter()
process.nextTick(() => {
emitter.emit('exit', 0)
Expand Down

0 comments on commit de3f676

Please sign in to comment.