Skip to content

Commit a0aaa14

Browse files
committed
feat: update to Jest 29 and support 27-29 in peer dependencies (#100)
1 parent 6fa39d9 commit a0aaa14

File tree

7 files changed

+590
-1071
lines changed

7 files changed

+590
-1071
lines changed

.eslintrc.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ module.exports = {
2828
'@typescript-eslint/no-require-imports': 'off',
2929
'@typescript-eslint/prefer-ts-expect-error': 'error',
3030
'@typescript-eslint/ban-types': 'error',
31-
'@typescript-eslint/no-unused-vars': 'error',
31+
'@typescript-eslint/no-unused-vars': [
32+
'error',
33+
{ argsIgnorePattern: '^_', caughtErrors: 'all' },
34+
],
3235
'no-else-return': 'error',
3336
'no-negated-condition': 'error',
3437
eqeqeq: ['error', 'smart'],

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,17 @@
4444
"testEnvironment": "node"
4545
},
4646
"dependencies": {
47-
"@jest/reporters": "^27.0.0",
47+
"@jest/reporters": "^29.0.2",
4848
"yoga-layout-prebuilt": "^1.10.0"
4949
},
5050
"devDependencies": {
5151
"@commitlint/cli": "^17.0.0",
5252
"@commitlint/config-conventional": "^17.0.0",
53-
"@jest/test-result": "^27.0.0",
54-
"@jest/types": "^27.0.0",
53+
"@jest/test-result": "^29.0.2",
54+
"@jest/types": "^29.0.2",
5555
"@semantic-release/changelog": "^6.0.0",
5656
"@semantic-release/git": "^10.0.0",
57-
"@types/jest": "^27.0.0",
57+
"@types/jest": "^29.0.0",
5858
"@types/node": "^16.0.0",
5959
"@types/react": "^17.0.39",
6060
"@typescript-eslint/eslint-plugin": "^5.0.0",
@@ -71,19 +71,19 @@
7171
"eslint-plugin-react-hooks": "^4.0.2",
7272
"husky": "^8.0.0",
7373
"ink": "^3.2.0",
74-
"jest": "^27.0.0",
75-
"jest-util": "^27.0.0",
74+
"jest": "^29.0.2",
75+
"jest-util": "^29.0.2",
7676
"lint-staged": "^13.0.0",
7777
"patch-package": "^6.2.2",
7878
"prettier": "^2.0.5",
7979
"react": "^17.0.2",
8080
"semantic-release": "^19.0.0",
8181
"slash": "^3.0.0",
82-
"ts-jest": "^27.0.0",
82+
"ts-jest": "^29.0.0-next.1",
8383
"typescript": "^4.0.0"
8484
},
8585
"peerDependencies": {
86-
"jest": "^27.0.0"
86+
"jest": "^27.0.0 || ^28.0.0 || ^29.0.0"
8787
},
8888
"engines": {
8989
"node": ">=10"

src/PostMessage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { AggregatedResult } from '@jest/test-result';
22
import type { Config } from '@jest/types';
3-
import type { Context } from '@jest/reporters';
3+
import type { TestContext } from '@jest/reporters';
44
import { testPathPatternToRegExp } from 'jest-util';
55
import * as React from 'react';
66
import { Box, Text } from 'ink';
@@ -88,7 +88,7 @@ const ContextInfo: React.FC<{ numberOfContexts: number }> = ({
8888
export const PostMessage: React.FC<{
8989
aggregatedResults: AggregatedResult;
9090
globalConfig: Config.GlobalConfig;
91-
contexts: Set<Context>;
91+
contexts: Set<TestContext>;
9292
}> = ({ aggregatedResults, globalConfig, contexts }) => {
9393
if (globalConfig.silent) {
9494
return null;

src/Reporter.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import type { Config } from '@jest/types';
66
import type { AggregatedResult, TestResult } from '@jest/test-result';
77
import {
88
BaseReporter,
9-
Context,
109
ReporterOnStartOptions,
1110
Test,
11+
TestContext,
1212
} from '@jest/reporters';
1313
import { SnapshotStatus } from './SnapshotStatus';
1414
import { Summary } from './Summary';
@@ -99,7 +99,7 @@ const CompletedTests: React.FC<{
9999
<Box paddingBottom={1} flexDirection="column">
100100
<Static items={completedTests}>
101101
{({ testResult, config }) => (
102-
<React.Fragment key={testResult.testFilePath + config.name}>
102+
<React.Fragment key={testResult.testFilePath + config.id}>
103103
<ResultHeader config={config} testResult={testResult} />
104104
<VerboseTestList
105105
testResult={testResult}
@@ -132,7 +132,7 @@ type DateEvents =
132132
testResult: TestResult;
133133
};
134134
}
135-
| { type: 'TestComplete'; payload: { contexts: Set<Context> } };
135+
| { type: 'TestComplete'; payload: { contexts: Set<TestContext> } };
136136

137137
type Props = {
138138
register: (cb: (events: DateEvents) => void) => void;
@@ -147,9 +147,9 @@ type State = {
147147
testResult: TestResult;
148148
config: Config.ProjectConfig;
149149
}>;
150-
currentTests: Array<[Config.Path, Config.ProjectConfig]>;
150+
currentTests: Array<[string, Config.ProjectConfig]>;
151151
done: boolean;
152-
contexts: Set<Context>;
152+
contexts: Set<TestContext>;
153153
};
154154

155155
const reporterReducer: React.Reducer<State, DateEvents> = (
@@ -199,7 +199,7 @@ const RunningTests: React.FC<{
199199
return (
200200
<Box paddingBottom={1} flexDirection="column">
201201
{tests.map(([path, config]) => (
202-
<Box key={path + config.name}>
202+
<Box key={path + config.id}>
203203
<Runs />
204204
<DisplayName config={config} />
205205
<FormattedPath
@@ -225,7 +225,7 @@ const Reporter: React.FC<Props> = ({
225225
completedTests: [],
226226
currentTests: [],
227227
done: false,
228-
contexts: new Set<Context>(),
228+
contexts: new Set<TestContext>(),
229229
});
230230

231231
React.useLayoutEffect(() => {
@@ -319,7 +319,10 @@ export default class ReactReporter extends BaseReporter {
319319
);
320320
}
321321

322-
async onRunComplete(contexts: Set<Context>) {
322+
async onRunComplete(
323+
contexts: Set<TestContext>,
324+
_aggregatedResults?: AggregatedResult,
325+
) {
323326
this._components.forEach(cb =>
324327
cb({ type: 'TestComplete', payload: { contexts } }),
325328
);

src/shared.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export const ResultHeader: React.FC<{
8181
export const FormattedPath: React.FC<{
8282
pad: number;
8383
config: Config.ProjectConfig | Config.GlobalConfig;
84-
testPath: Config.Path;
84+
testPath: string;
8585
columns: number | undefined;
8686
}> = ({ pad, config, testPath, columns }) => {
8787
const maxLength = (columns || Number.NaN) - pad;
@@ -135,7 +135,7 @@ export const FormattedPath: React.FC<{
135135

136136
export const FormatFullTestPath: React.FC<{
137137
config: Config.GlobalConfig | Config.ProjectConfig;
138-
testPath: Config.Path;
138+
testPath: string;
139139
}> = ({ config, testPath }) => (
140140
// TODO: maybe not 9000? We just don't want to trim it
141141
<FormattedPath config={config} testPath={testPath} pad={0} columns={9000} />

src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { Config } from '@jest/types';
33

44
export const relativePath = (
55
config: Config.GlobalConfig | Config.ProjectConfig,
6-
testPath: Config.Path,
6+
testPath: string,
77
) => {
88
// this function can be called with ProjectConfigs or GlobalConfigs. GlobalConfigs
99
// do not have config.cwd, only config.rootDir. Try using config.cwd, fallback

0 commit comments

Comments
 (0)