Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"node": ">=18"
},
"scripts": {
"prebuild": "rimraf dist",
"prebuild": "node -e \"fs.rmSync('dist',{recursive:true,force:true})\"",
"build": "npm-run-all --parallel build:main build:bundle:main build:bundle:pure",
"build:bundle:main": "dotenv -e .bundle.main.env kcd-scripts build -- --bundle --no-clean --no-ts-defs",
"build:bundle:pure": "dotenv -e .bundle.main.env -e .bundle.pure.env kcd-scripts build -- --bundle --no-clean --no-ts-defs",
Expand Down Expand Up @@ -52,14 +52,13 @@
"@testing-library/jest-dom": "^5.11.6",
"@types/react": "^19.0.0",
"@types/react-dom": "^19.0.0",
"chalk": "^4.1.2",
"dotenv-cli": "^4.0.0",
"jest-diff": "^29.7.0",
"kcd-scripts": "^13.0.0",
"npm-run-all2": "^6.2.6",
"picocolors": "^1.1.1",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"rimraf": "^3.0.2",
"typescript": "^5.9.3"
},
"peerDependencies": {
Expand Down
16 changes: 7 additions & 9 deletions tests/failOnUnexpectedConsoleCalls.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ SOFTWARE.
/* eslint-disable prefer-template */
/* eslint-disable func-names */
const util = require('util')
const chalk = require('chalk')
const pc = require('picocolors')
const shouldIgnoreConsoleError = require('./shouldIgnoreConsoleError')

const patchConsoleMethod = (methodName, unexpectedConsoleCallStacks) => {
Expand Down Expand Up @@ -69,23 +69,21 @@ const flushUnexpectedConsoleCalls = (
if (unexpectedConsoleCallStacks.length > 0) {
const messages = unexpectedConsoleCallStacks.map(
([stack, message]) =>
`${chalk.red(message)}\n` +
`${pc.red(message)}\n` +
`${stack
.split('\n')
.map(line => chalk.gray(line))
.map(line => pc.gray(line))
.join('\n')}`,
)

const message =
`Expected test not to call ${chalk.bold(
`console.${methodName}()`,
)}.\n\n` +
`Expected test not to call ${pc.bold(`console.${methodName}()`)}.\n\n` +
'If the warning is expected, test for it explicitly by:\n' +
`1. Using the ${chalk.bold('.' + expectedMatcher + '()')} ` +
`1. Using the ${pc.bold('.' + expectedMatcher + '()')} ` +
`matcher, or...\n` +
`2. Mock it out using ${chalk.bold(
`2. Mock it out using ${pc.bold(
'spyOnDev',
)}(console, '${methodName}') or ${chalk.bold(
)}(console, '${methodName}') or ${pc.bold(
'spyOnProd',
)}(console, '${methodName}'), and test that the warning occurs.`

Expand Down