Skip to content

Commit 61ff493

Browse files
committed
ci: allow intrastructure to deal with testing babel@next
1 parent 1de83cd commit 61ff493

File tree

3 files changed

+29
-5
lines changed

3 files changed

+29
-5
lines changed

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ export {
2424
};
2525

2626
if ('expect' in globalThis && typeof expect.addSnapshotSerializer === 'function') {
27-
debug(
27+
debug.message(
2828
'added unstring snapshot serializer globally; all snapshots after this point will be affected'
2929
);
3030
expect.addSnapshotSerializer(unstringSnapshotSerializer);
3131
} else {
3232
/* istanbul ignore next */
33-
debug(
33+
debug.warn(
3434
'unable to add unstring snapshot serializer: global expect object is missing or unsupported'
3535
);
3636
}

test/integration/.config.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export const BABEL_VERSIONS_UNDER_TEST = ([
5757
// * [babel@version, ...otherPackages]
5858
[`@babel/core@${babelCoreMinimumVersion.version}`], // ? Current minimum version
5959
['@babel/core@latest'], // ? Latest version
60+
// ! Canary/next version should always be last (so Jest can skip it for now)
6061
['@babel/core@next'], // ? Next version
6162
]);
6263

@@ -74,14 +75,15 @@ export const NODE_VERSIONS_UNDER_TEST = packageEngines.node
7475

7576
export const FRAMEWORKS_UNDER_TEST: FrameworksUnderTest = [
7677
{
77-
frameworkPkg: 'jest@>=30 || >=30.0.0-alpha.2',
78+
frameworkPkg: 'jest@latest',
7879
frameworkArgs: ['jest'],
7980
tests: [
8081
{ source: assets.invocation, expectations: expectSuccessAndOutput },
8182
{ source: assets.invocationOnly, expectations: expectSuccess },
8283
{ source: assets.invocationSkip, expectations: expectSuccess },
8384
{ source: assets.invocationSnapshot, expectations: expectSuccess }
84-
]
85+
],
86+
skipLastBabelVersionUnderTest: true
8587
},
8688
{
8789
frameworkPkg: 'vitest@latest',
@@ -168,6 +170,14 @@ export type FrameworksUnderTest = ReadonlyDeep<
168170
frameworkPkg: string;
169171
frameworkArgs: string[];
170172
otherFrameworkPkgs?: string[];
173+
/**
174+
* TODO: Try to fix this next time you see this!
175+
* Only applies to integration-smoke.test.ts. Useful because babel@8 and
176+
* babel-jest are incompatible for a couple reasons, including breaking API
177+
* changes from babel@8 as well as jest not handling cjs-importing-esm
178+
* properly (a fix is monkey-patched in via a @-xun/jest helper method).
179+
*/
180+
skipLastBabelVersionUnderTest?: boolean;
171181
tests: {
172182
source: Record<
173183
(typeof IMPORT_SPECIFIERS_UNDER_TEST)[number],

test/integration/integration-smoke.test.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,27 @@ beforeAll(async () => {
5252

5353
let counter = 1;
5454

55-
for (const [babelPackage, ...otherBabelPkgs] of BABEL_VERSIONS_UNDER_TEST) {
55+
for (const [
56+
index,
57+
[babelPackage, ...otherBabelPkgs]
58+
] of BABEL_VERSIONS_UNDER_TEST.entries()) {
5659
for (const {
5760
frameworkPkg,
5861
frameworkArgs,
5962
otherFrameworkPkgs,
63+
skipLastBabelVersionUnderTest = false,
6064
tests
6165
} of FRAMEWORKS_UNDER_TEST) {
66+
if (skipLastBabelVersionUnderTest && index >= BABEL_VERSIONS_UNDER_TEST.length - 1) {
67+
debug.warn(
68+
'saw skipLastBabelVersionUnderTest=true in FRAMEWORKS_UNDER_TEST entry; skipped testing %O with %O',
69+
babelPackage,
70+
frameworkPkg
71+
);
72+
73+
continue;
74+
}
75+
6276
const otherPkgs = otherBabelPkgs.concat(otherFrameworkPkgs || []);
6377
const pkgsString = [babelPackage, frameworkPkg, ...otherPkgs].join(', ');
6478

0 commit comments

Comments
 (0)