From af588fb82ad81b7c2e1fdeb5465832b3e2a645f7 Mon Sep 17 00:00:00 2001 From: iHiD <286476+iHiD@users.noreply.github.com> Date: Sun, 22 Nov 2026 19:36:07 +0900 Subject: [PATCH 1/4] Find the tests in the test file with acorn, without loading TypeScript The reporter parsed the test file with @exercism/static-analysis, which uses @typescript-eslint/typescript-estree and so loads the whole TypeScript compiler on every run. Test files are plain JavaScript, so acorn reads them as well. On all 180 spec files in the track and the fixtures, the new code finds the same tests, names, task IDs, code and locations. Co-authored-by: iHiD <286476+iHiD@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 --- package.json | 4 +- pnpm-lock.yaml | 140 +---------------------------------- src/output.ts | 50 ++++--------- src/tests.ts | 197 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 217 insertions(+), 174 deletions(-) create mode 100644 src/tests.ts diff --git a/package.json b/package.json index 0c3ee3d..81a9948 100644 --- a/package.json +++ b/package.json @@ -28,13 +28,11 @@ }, "dependencies": { "@exercism/babel-preset-javascript": "^0.7.0", - "@exercism/static-analysis": "^0.14.0", "@jest/console": "^30.4.0", "@jest/reporters": "^30.4.0", "@jest/test-result": "^30.4.0", "@jest/types": "^30.4.0", - "@typescript-eslint/typescript-estree": "^8.37.0", - "@typescript-eslint/visitor-keys": "^8.37.0", + "acorn": "^8.15.0", "babel-jest": "^30.4.0", "chalk": "^6.0.0", "core-js": "^3.44.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b91f1a2..9ec1202 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,9 +11,6 @@ importers: '@exercism/babel-preset-javascript': specifier: ^0.7.0 version: 0.7.0 - '@exercism/static-analysis': - specifier: ^0.14.0 - version: 0.14.0(@typescript-eslint/typescript-estree@8.63.0(typescript@5.7.3))(@typescript-eslint/visitor-keys@8.72.1) '@jest/console': specifier: ^30.4.0 version: 30.5.2 @@ -26,12 +23,9 @@ importers: '@jest/types': specifier: ^30.4.0 version: 30.5.1 - '@typescript-eslint/typescript-estree': - specifier: ^8.37.0 - version: 8.63.0(typescript@5.7.3) - '@typescript-eslint/visitor-keys': - specifier: ^8.37.0 - version: 8.72.1 + acorn: + specifier: ^8.15.0 + version: 8.15.0 babel-jest: specifier: ^30.4.0 version: 30.5.2(@babel/core@7.29.7) @@ -781,12 +775,6 @@ packages: eslint: '>= 9.28' typescript: ~5.7.3 - '@exercism/static-analysis@0.14.0': - resolution: {integrity: sha512-ZqaT7PBAolrejONdsmiE+YgQ1GmTjuGtIIquk69CowwNBaiBsy6VMg9hXOJNEk3ELUxKDT8IBQzdmtEk7PqgOA==} - peerDependencies: - '@typescript-eslint/typescript-estree': ^8.0.1 - '@typescript-eslint/visitor-keys': ^8.0.1 - '@humanfs/core@0.19.1': resolution: {integrity: sha512-5DyQ4+1JEUzejeK1JGICcideyfUbGixgS9jNgex5nqkW+cY7WZhxBigmieN5Qnw9ZosSNVC9KQKyb+GUaGyKUA==} engines: {node: '>=18.18.0'} @@ -1120,12 +1108,6 @@ packages: peerDependencies: typescript: '>=4.8.4 <5.9.0' - '@typescript-eslint/project-service@8.63.0': - resolution: {integrity: sha512-e5dh0/UI0ok53AlZ5wRkXCB32z/f2jUZqPR/ygAw5WYaSw8j9EoJWlS7wQjr/dmOaqWjnPIn2m+HhVPCMWGZVQ==} - engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - peerDependencies: - typescript: '>=4.8.4 <6.1.0' - '@typescript-eslint/scope-manager@8.0.1': resolution: {integrity: sha512-NpixInP5dm7uukMiRyiHjRKkom5RIFA4dfiHvalanD2cF0CLUuQqxfg8PtEUo9yqJI2bBhF+pcSafqnG3UBnRQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} @@ -1140,12 +1122,6 @@ packages: peerDependencies: typescript: '>=4.8.4 <5.9.0' - '@typescript-eslint/tsconfig-utils@8.63.0': - resolution: {integrity: sha512-sUAbkulqBAsncKnbRP3+7CtQFRKicexnj7ZwNC6ddCR7EmrXvjvdCYMJbUIqMd6lwoEriZjwLo08aS5tSjVMHg==} - engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - peerDependencies: - typescript: '>=4.8.4 <6.1.0' - '@typescript-eslint/type-utils@8.37.0': resolution: {integrity: sha512-SPkXWIkVZxhgwSwVq9rqj/4VFo7MnWwVaRNznfQDc/xPYHjXnPfLWn+4L6FF1cAz6e7dsqBeMawgl7QjUMj4Ow==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} @@ -1161,14 +1137,6 @@ packages: resolution: {integrity: sha512-ax0nv7PUF9NOVPs+lmQ7yIE7IQmAf8LGcXbMvHX5Gm+YJUYNAl340XkGnrimxZ0elXyoQJuN5sbg6C4evKA4SQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@typescript-eslint/types@8.63.0': - resolution: {integrity: sha512-xyLtl9DUBBFrcJS4x2pIqGLH68/tC2uOa4Z7pUteW09D3bXnnXUom4dyPikzWgB7llmIc1zoeI3aoUdC4rPK/Q==} - engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - - '@typescript-eslint/types@8.72.1': - resolution: {integrity: sha512-LmE5IhQet1BWOWEXqBrVtBPsMAOQ6Nzk35d+WLh3mk4EUF33sqlfxjio1MdYeSvKSG5skactKKuixBIKXhL4Rw==} - engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@typescript-eslint/typescript-estree@8.0.1': resolution: {integrity: sha512-8V9hriRvZQXPWU3bbiUV4Epo7EvgM6RTs+sUmxp5G//dBGy402S7Fx0W0QkB2fb4obCF8SInoUzvTYtc3bkb5w==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} @@ -1184,12 +1152,6 @@ packages: peerDependencies: typescript: '>=4.8.4 <5.9.0' - '@typescript-eslint/typescript-estree@8.63.0': - resolution: {integrity: sha512-ygBkU+B7ex5UI/gKhaqexWev79uISfIv7XQCRNYO/jmD8rGLPyWLAb3KMRT6nd8Gt9bmUBi9+iX6tBdYfOY81Q==} - engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - peerDependencies: - typescript: '>=4.8.4 <6.1.0' - '@typescript-eslint/utils@8.0.1': resolution: {integrity: sha512-CBFR0G0sCt0+fzfnKaciu9IBsKvEKYwN9UZ+eeogK1fYHg4Qxk1yf/wLQkLXlq8wbU2dFlgAesxt8Gi76E8RTA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} @@ -1211,14 +1173,6 @@ packages: resolution: {integrity: sha512-YzfhzcTnZVPiLfP/oeKtDp2evwvHLMe0LOy7oe+hb9KKIumLNohYS9Hgp1ifwpu42YWxhZE8yieggz6JpqO/1w==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@typescript-eslint/visitor-keys@8.63.0': - resolution: {integrity: sha512-UexrHGnGTpbuQHct2ExOc2ZcFbGUS9FOesCxxqdBGcpI1BxYu/LZ6U8Aq6/72XtF/qRBk9nhuGHFJIXXMhPMdw==} - engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - - '@typescript-eslint/visitor-keys@8.72.1': - resolution: {integrity: sha512-SB8xqipSzZHUePCCLNeYxqnxq83X61/qzNhjQGbTfjxGZIeOEP7tBgWYX05Tcd6CgE02WdTJnh5b8kMZJ/+bnQ==} - engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@ungap/structured-clone@1.4.0': resolution: {integrity: sha512-1mEZtMKPM09vDmQt5y7YvmN2+DFTP7Tg0EWXdic8/C6VRnpb33e4ghisCIE3WZjsE2N8mf+QV1Zqh7ZFYLWInQ==} @@ -1460,10 +1414,6 @@ packages: resolution: {integrity: sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==} engines: {node: 20 || >=22} - brace-expansion@5.0.7: - resolution: {integrity: sha512-7oFy703dxfY3/NLxC1fh2SUCQ0H9rmAY+5EpDVfXjUTTs+HEwR2nYaqLv+GWcTsumwxPfiz6CzCNkwXwBUwqCA==} - engines: {node: 18 || 20 || >=22} - braces@3.0.3: resolution: {integrity: sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==} engines: {node: '>=8'} @@ -1744,10 +1694,6 @@ packages: resolution: {integrity: sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - eslint-visitor-keys@5.0.1: - resolution: {integrity: sha512-tD40eHxA35h0PEIZNeIjkHoDR4YjjJp34biM0mDvplBe//mB+IHCqHDGV7pxF+7MklTvighcCPPZC7ynWyjdTA==} - engines: {node: ^20.19.0 || ^22.13.0 || >=24} - eslint@9.31.0: resolution: {integrity: sha512-QldCVh/ztyKJJZLr4jXNUByx3gR+TDYZCRXEktiZoUR3PGy4qCmSbkxcIle8GEwGpb5JBZazlaJ/CxLidXdEbQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} @@ -2428,10 +2374,6 @@ packages: resolution: {integrity: sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==} engines: {node: '>=6'} - minimatch@10.2.5: - resolution: {integrity: sha512-MULkVLfKGYDFYejP07QOurDLLQpcjk7Fw+7jXS2R2czRQzR56yHRveU5NDJEOviH+hETZKSkIk5c+T23GjFUMg==} - engines: {node: 18 || 20 || >=22} - minimatch@10.2.6: resolution: {integrity: sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==} engines: {node: 18 || 20 || >=22} @@ -2580,10 +2522,6 @@ packages: resolution: {integrity: sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==} engines: {node: '>=8.6'} - picomatch@4.0.5: - resolution: {integrity: sha512-RvwwcruNjI1ncT5xRakeyS9Lf8lcItv34KD+aif+VH9kduAyfYBipGh12274xtenIPZ119/R9BdTBa8gAwSh0A==} - engines: {node: '>=12'} - picomatch@4.0.7: resolution: {integrity: sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==} engines: {node: '>=12'} @@ -2865,10 +2803,6 @@ packages: resolution: {integrity: sha512-u9E6A+ZDYdp7a4WnarkXPZOx8Ilz46+kby6p1yZ8zsGTz9gYa6FIS7lj2oezzNKmtdyyJNNmmXDppga5GB7kSw==} engines: {node: '>=18'} - tinyglobby@0.2.17: - resolution: {integrity: sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==} - engines: {node: '>=12.0.0'} - to-regex-range@5.0.1: resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==} engines: {node: '>=8.0'} @@ -3943,11 +3877,6 @@ snapshots: - jest - supports-color - '@exercism/static-analysis@0.14.0(@typescript-eslint/typescript-estree@8.63.0(typescript@5.7.3))(@typescript-eslint/visitor-keys@8.72.1)': - dependencies: - '@typescript-eslint/typescript-estree': 8.63.0(typescript@5.7.3) - '@typescript-eslint/visitor-keys': 8.72.1 - '@humanfs/core@0.19.1': {} '@humanfs/node@0.16.6': @@ -4425,15 +4354,6 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/project-service@8.63.0(typescript@5.7.3)': - dependencies: - '@typescript-eslint/tsconfig-utils': 8.63.0(typescript@5.7.3) - '@typescript-eslint/types': 8.63.0 - debug: 4.4.3 - typescript: 5.7.3 - transitivePeerDependencies: - - supports-color - '@typescript-eslint/scope-manager@8.0.1': dependencies: '@typescript-eslint/types': 8.0.1 @@ -4448,10 +4368,6 @@ snapshots: dependencies: typescript: 5.7.3 - '@typescript-eslint/tsconfig-utils@8.63.0(typescript@5.7.3)': - dependencies: - typescript: 5.7.3 - '@typescript-eslint/type-utils@8.37.0(eslint@9.31.0)(typescript@5.7.3)': dependencies: '@typescript-eslint/types': 8.37.0 @@ -4468,10 +4384,6 @@ snapshots: '@typescript-eslint/types@8.37.0': {} - '@typescript-eslint/types@8.63.0': {} - - '@typescript-eslint/types@8.72.1': {} - '@typescript-eslint/typescript-estree@8.0.1(typescript@5.7.3)': dependencies: '@typescript-eslint/types': 8.0.1 @@ -4503,21 +4415,6 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/typescript-estree@8.63.0(typescript@5.7.3)': - dependencies: - '@typescript-eslint/project-service': 8.63.0(typescript@5.7.3) - '@typescript-eslint/tsconfig-utils': 8.63.0(typescript@5.7.3) - '@typescript-eslint/types': 8.63.0 - '@typescript-eslint/visitor-keys': 8.63.0 - debug: 4.4.3 - minimatch: 10.2.5 - semver: 7.8.5 - tinyglobby: 0.2.17 - ts-api-utils: 2.5.0(typescript@5.7.3) - typescript: 5.7.3 - transitivePeerDependencies: - - supports-color - '@typescript-eslint/utils@8.0.1(eslint@9.31.0)(typescript@5.7.3)': dependencies: '@eslint-community/eslint-utils': 4.4.0(eslint@9.31.0) @@ -4550,16 +4447,6 @@ snapshots: '@typescript-eslint/types': 8.37.0 eslint-visitor-keys: 4.2.1 - '@typescript-eslint/visitor-keys@8.63.0': - dependencies: - '@typescript-eslint/types': 8.63.0 - eslint-visitor-keys: 5.0.1 - - '@typescript-eslint/visitor-keys@8.72.1': - dependencies: - '@typescript-eslint/types': 8.72.1 - eslint-visitor-keys: 5.0.1 - '@ungap/structured-clone@1.4.0': {} '@unrs/resolver-binding-android-arm-eabi@1.13.0': @@ -4794,10 +4681,6 @@ snapshots: dependencies: balanced-match: 4.0.4 - brace-expansion@5.0.7: - dependencies: - balanced-match: 4.0.4 - braces@3.0.3: dependencies: fill-range: 7.1.1 @@ -5096,8 +4979,6 @@ snapshots: eslint-visitor-keys@4.2.1: {} - eslint-visitor-keys@5.0.1: {} - eslint@9.31.0: dependencies: '@eslint-community/eslint-utils': 4.4.0(eslint@9.31.0) @@ -5212,10 +5093,6 @@ snapshots: dependencies: bser: 2.1.2 - fdir@6.5.0(picomatch@4.0.5): - optionalDependencies: - picomatch: 4.0.5 - fdir@6.5.0(picomatch@4.0.7): optionalDependencies: picomatch: 4.0.7 @@ -6064,10 +5941,6 @@ snapshots: mimic-fn@2.1.0: {} - minimatch@10.2.5: - dependencies: - brace-expansion: 5.0.7 - minimatch@10.2.6: dependencies: brace-expansion: 5.0.12 @@ -6209,8 +6082,6 @@ snapshots: picomatch@2.3.2: {} - picomatch@4.0.5: {} - picomatch@4.0.7: {} pify@4.0.1: {} @@ -6515,11 +6386,6 @@ snapshots: glob: 10.5.0 minimatch: 10.2.6 - tinyglobby@0.2.17: - dependencies: - fdir: 6.5.0(picomatch@4.0.5) - picomatch: 4.0.5 - to-regex-range@5.0.1: dependencies: is-number: 7.0.0 diff --git a/src/output.ts b/src/output.ts index 6ec9fb8..8ecf069 100644 --- a/src/output.ts +++ b/src/output.ts @@ -1,6 +1,4 @@ /* eslint-disable @typescript-eslint/naming-convention */ -import { AstParser, extractTests } from '@exercism/static-analysis' -import type { ExtractedTestCase, ParsedSource } from '@exercism/static-analysis' import type { ConsoleBuffer } from '@jest/console' import type { AggregatedResult, @@ -10,6 +8,8 @@ import type { import type { Config } from '@jest/types' import fs from 'fs' import path from 'path' +import { parseTests } from './tests' +import type { ParsedTests, TestCase } from './tests' interface OutputInterface { status: 'fail' | 'pass' | 'error' @@ -42,8 +42,7 @@ export class Output { Pick private readonly globalConfig: Config.GlobalConfig private readonly outputFile: string - private readonly sources: Record - private readonly tests: Record> + private readonly sources: Record private readonly config: null | ExerciseConfig constructor(globalConfig: Config.GlobalConfig) { @@ -54,7 +53,6 @@ export class Output { this.config = findConfig(path.dirname(this.outputFile)) this.sources = {} - this.tests = {} } public error(message: string): void { @@ -130,9 +128,8 @@ export class Output { const parsedSources: Record< string, { - program: ParsedSource['program'] - source: ParsedSource['source'] - tests: Record + source: string + tests: Record } > = {} @@ -142,22 +139,15 @@ export class Output { .filter((path, index, self) => self.indexOf(path) === index) .forEach((file) => { try { - const [{ program, source }] = AstParser.ANALYZER.parseSync( - fs.readFileSync(file).toString() - ) - const tests = extractTests(program) + const { source, tests } = parseTests(fs.readFileSync(file).toString()) parsedSources[file] = { - program, source, - tests: tests.reduce>( - (results, item) => { - results[item.name(' > ')] = item - results[item.name(' ' as ' > ')] = item - return results - }, - {} - ), + tests: tests.reduce>((results, item) => { + results[item.name(' > ')] = item + results[item.name(' ' as ' > ')] = item + return results + }, {}), } } catch (err: unknown) { console.error( @@ -238,22 +228,14 @@ export class Output { }) } - private getSource(specFilePath: string): { - source: ParsedSource - tests: ExtractedTestCase[] - } { + private getSource(specFilePath: string): ParsedTests { if (!this.sources[specFilePath]) { - const [{ program, source }] = AstParser.ANALYZER.parseSync( + this.sources[specFilePath] = parseTests( fs.readFileSync(specFilePath).toString() ) - this.tests[specFilePath] = extractTests(program) - this.sources[specFilePath] = { program, source } } - return { - source: this.sources[specFilePath], - tests: this.tests[specFilePath], - } + return this.sources[specFilePath] } public testInnerFinished( @@ -302,7 +284,7 @@ export class Output { function buildOutput( specFilePath: string, buffer: ConsoleBuffer, - { tests }: { source: ParsedSource; tests: ExtractedTestCase[] } + { tests }: ParsedTests ): Record { const outputs = buffer.reduce>((outputs, entry) => { // The origin stack trace will look something like this: @@ -320,7 +302,7 @@ function buildOutput( // ... // }) - let foundTest: ExtractedTestCase | undefined + let foundTest: TestCase | undefined // Using find because it will break when something is found! entry.origin.split('\n').find((originLine) => { if (!originLine.includes(specFilePath)) { diff --git a/src/tests.ts b/src/tests.ts new file mode 100644 index 0000000..dd01706 --- /dev/null +++ b/src/tests.ts @@ -0,0 +1,197 @@ +// Finds the tests in a test file, so the reporter can show each test's code +// and work out which test printed each console message. +// +// This used to be done by @exercism/static-analysis, which parses with +// @typescript-eslint/typescript-estree. That package loads the whole +// TypeScript compiler (about 9 MB of JavaScript) on every run, which took +// about a quarter of each run. Test files are plain JavaScript, so acorn, a +// small JavaScript parser, can read them in a fraction of the time. +import { parse } from 'acorn' +import type { + AnyNode, + ArrowFunctionExpression, + CallExpression, + Expression, + FunctionExpression, + Literal, + Node, + SourceLocation, +} from 'acorn' + +type TestFunction = (FunctionExpression | ArrowFunctionExpression) & { + loc: SourceLocation +} + +export interface TestCase { + /** The function passed to test(...) */ + testNode: TestFunction + description: string[] + test: string + /** The number of top-level describe blocks up to and including this test */ + topLevelIndex: number + name: (glue?: string) => string + testCode: (source: string) => string +} + +export interface ParsedTests { + source: string + tests: TestCase[] +} + +const DESCRIBES = ['describe', 'xdescribe'] +const TESTS = ['test', 'xtest', 'it', 'xit'] +const MODIFIERS = ['skip', 'only'] + +function isIdentifier(node: Node, names: string[]): boolean { + return ( + node.type === 'Identifier' && + names.includes((node as AnyNode & { name: string }).name) + ) +} + +function isStringLiteral( + node: Node | undefined +): node is Literal & { value: string } { + return node?.type === 'Literal' && typeof (node as Literal).value === 'string' +} + +// describe('...'), describe.skip('...'), xdescribe.only('...') and so on +function isDescribe(node: Expression): boolean { + if (node.type !== 'CallExpression') return false + const { callee } = node + if (callee.type === 'Identifier') return DESCRIBES.includes(callee.name) + return ( + callee.type === 'MemberExpression' && + isIdentifier(callee.object, DESCRIBES) && + (isIdentifier(callee.property, MODIFIERS) || + (isStringLiteral(callee.property) && + MODIFIERS.includes(callee.property.value))) + ) +} + +// test('...'), it.skip('...'), xtest.only('...') and so on +function isTest(node: Expression): boolean { + if (node.type !== 'CallExpression') return false + const { callee } = node + if (callee.type === 'Identifier') return TESTS.includes(callee.name) + return ( + callee.type === 'MemberExpression' && + isIdentifier(callee.object, TESTS) && + isIdentifier(callee.property, MODIFIERS) + ) +} + +function isTestFunction(node: Node | undefined): node is TestFunction { + return ( + node?.type === 'FunctionExpression' || + node?.type === 'ArrowFunctionExpression' + ) +} + +function sourceOf(source: string, node: Node): string { + return source.substring(node.start, node.end) +} + +function isNode(value: unknown): value is Node { + return ( + typeof value === 'object' && + value !== null && + typeof (value as { type?: unknown }).type === 'string' + ) +} + +function children(node: Node): Node[] { + const result: Node[] = [] + Object.entries(node).forEach(([key, value]) => { + if (key === 'loc') return + if (Array.isArray(value)) { + value.forEach((item) => { + if (isNode(item)) result.push(item) + }) + } else if (isNode(value)) { + result.push(value) + } + }) + return result +} + +/** + * Finds the tests in the same way as @exercism/static-analysis did. Tests + * and describe blocks named with anything other than a string literal (such + * as a template literal) are left out. + */ +export function parseTests(source: string): ParsedTests { + const program = parse(source, { + ecmaVersion: 'latest', + sourceType: 'module', + locations: true, + allowHashBang: true, + }) + + const tests: TestCase[] = [] + const description: string[] = [] + let topLevelDescribes = 0 + + function visit(node: Node): void { + if (node.type === 'ExpressionStatement') { + const { expression } = node as AnyNode & { expression: Expression } + + if (isDescribe(expression)) { + const [nameArgument] = (expression as CallExpression).arguments + if (!isStringLiteral(nameArgument)) return + + if (description.length === 0) topLevelDescribes += 1 + description.push(nameArgument.value) + children(node).forEach(visit) + description.pop() + return + } + + if (isTest(expression)) { + const [nameArgument, testArgument] = (expression as CallExpression) + .arguments + if (isStringLiteral(nameArgument) && isTestFunction(testArgument)) { + tests.push( + createTestCase( + testArgument, + [...description], + nameArgument.value, + topLevelDescribes + ) + ) + } + return + } + } + + children(node).forEach(visit) + } + + visit(program) + return { source, tests } +} + +function createTestCase( + testNode: TestFunction, + description: string[], + test: string, + topLevelIndex: number +): TestCase { + return { + testNode, + description, + test, + topLevelIndex, + name(glue = ' > '): string { + return [...description, test].join(glue) + }, + testCode(source: string): string { + if (testNode.body.type === 'BlockStatement') { + return testNode.body.body + .map((statement) => sourceOf(source, statement)) + .join('\n') + } + return sourceOf(source, testNode.body) + }, + } +} From e7a44d4a9e4fe998bfe701e3cf610a0de249905a Mon Sep 17 00:00:00 2001 From: iHiD <286476+iHiD@users.noreply.github.com> Date: Tue, 24 Nov 2026 19:19:44 +0900 Subject: [PATCH 2/4] Run the tests with Node's built-in test runner instead of Jest Jest took almost all of each run: it set up its runtime and loaded Babel, which compiled every file to CommonJS. Node's test runner now runs the test file as a native ES module in the same process. src/setup.mts preloads a module hook, src/jest-globals.mts provides the Jest API the track uses (on Jest's expect and jest-mock), and src/reporter.mts turns the runner's events into the results src/output.ts writes, as before. jest.mock calls run before the test file loads, as Jest hoisted them, using Node's mock.module. A test without `done` waits one turn of the event loop for unhandled rejections, unless it has already used up its 5 seconds. Node reports a test file that defines no tests as one passing test, and the reporter reports that the file failed to run, as Jest did. Co-authored-by: iHiD <286476+iHiD@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 --- babel.config.js | 6 - bin/run.sh | 179 ++--- eslint.config.mjs | 2 - jest.runner.config.js | 8 - package.json | 12 +- pnpm-lock.yaml | 684 ++++++------------ pnpm-workspace.yaml | 2 - src/jest-globals.mts | 238 ++++++ src/jest/setup.ts | 5 - src/output.ts | 75 +- src/reporter.mts | 165 +++++ src/reporter.ts | 73 -- src/setup.mts | 48 ++ src/syntax-error.ts | 75 ++ .../two-fer/error/empty/expected_results.json | 6 + .../two-fer/{fail => error}/empty/two-fer.js | 0 .../{fail => error}/empty/two-fer.spec.js | 0 .../error/syntax/expected_results.json | 2 +- .../two-fer/fail/empty/expected_results.json | 27 - test/smoke.test.mjs | 6 +- 20 files changed, 855 insertions(+), 758 deletions(-) delete mode 100644 babel.config.js delete mode 100644 jest.runner.config.js delete mode 100644 pnpm-workspace.yaml create mode 100644 src/jest-globals.mts delete mode 100644 src/jest/setup.ts create mode 100644 src/reporter.mts delete mode 100644 src/reporter.ts create mode 100644 src/setup.mts create mode 100644 src/syntax-error.ts create mode 100644 test/fixtures/two-fer/error/empty/expected_results.json rename test/fixtures/two-fer/{fail => error}/empty/two-fer.js (100%) rename test/fixtures/two-fer/{fail => error}/empty/two-fer.spec.js (100%) delete mode 100644 test/fixtures/two-fer/fail/empty/expected_results.json diff --git a/babel.config.js b/babel.config.js deleted file mode 100644 index c30cc1a..0000000 --- a/babel.config.js +++ /dev/null @@ -1,6 +0,0 @@ -// This file is only used by jest.runner.config.js, when running the -// test-runner. The tool itself uses typescript's compilation instead. -module.exports = { - presets: [['@exercism/babel-preset-javascript', { corejs: '3.44' }]], - plugins: [], -} diff --git a/bin/run.sh b/bin/run.sh index 17333d4..1937b59 100755 --- a/bin/run.sh +++ b/bin/run.sh @@ -77,9 +77,8 @@ OUTPUT="${OUTPUT%/}/" set -euo pipefail ROOT="$(realpath $(dirname "$0")/..)" -REPORTER="$ROOT/dist/reporter.js" -SETUP="$ROOT/dist/jest/setup.js" -CONFIG="$ROOT/jest.runner.config.js" +REPORTER="$ROOT/dist/reporter.mjs" +SETUP="$ROOT/dist/setup.mjs" echo " " echo "╔═════════════════════════════════════════════════════════════╗" @@ -95,9 +94,9 @@ echo "✔️ Using base-root: $ROOT" echo "✔️ Using setup-env: $SETUP" if test -f "$REPORTER"; then - echo "✔️ reporter.js found, test runner was built" + echo "✔️ reporter.mjs found, test runner was built" else - >&2 echo "❌ Expected reporter.js to exist." + >&2 echo "❌ Expected reporter.mjs to exist." >&2 echo "❌ Did you forget to 'corepack pnpm build' first?" >&2 echo "" >&2 echo "👁️ The following files exist in the dist folder (build output):" @@ -153,59 +152,6 @@ if test -f "${OUTPUT}.npmrc"; then mv "${OUTPUT}.npmrc" "${OUTPUT}.npmrc.💥.bak" || true fi; -COREPACK_ROOT_DIR=$(pwd) - -if [[ "${OUTPUT}" =~ "$ROOT" ]]; then - echo "" - echo "The output directory seems to be placed inside the test " - echo "runner root. This means the CLI tools we run will use the " - echo "configuration files as given by the test-runner for running " - echo "the tests, which is what we want. No need to turn the output " - echo "directory into a standalone package." - echo "" - - if test -f "${OUTPUT}pnpm-lock.yaml"; then - echo "✔️ renaming pnpm-lock in output to prevent pnpm from " - echo " interpreting this directory as a standalone package." - mv "${OUTPUT}pnpm-lock.yaml" "${OUTPUT}pnpm-lock.yaml.💥.bak" || true - fi; - - echo "" -else - echo "" - echo "The output directory is likely not placed inside the test " - echo "runner root. This means the CLI tools need configuration " - echo "files as given and understood by the test-runner for running " - echo "the tests. Will now turn the output directory into a " - echo "standalone package." - echo "" - - COREPACK_ROOT_DIR="${OUTPUT}" - - echo "✔️ pnpm cache from root to output" - # cd $ROOT && corepack pnpm deploy --filter @exercism/javascript-test-runner --ignore-scripts "${OUTPUT}deploy" - # mv "${OUTPUT}deploy/node_modules" "${OUTPUT}" - # Link to the installed packages instead of copying them. The folder holds - # about 26,000 files, so copying it took over a second with a warm disk - # cache and over 15 seconds with a cold one. Node resolves the link to the - # real folder, so packages load from the image as before. - ln -s "${ROOT}/node_modules" "${OUTPUT}node_modules" - - echo "✔️ .pnpm-lock.yaml from root to output" - cp "${ROOT}/pnpm-lock.yaml" "${OUTPUT}pnpm-lock.yaml" - - echo "✔️ babel.config.js from root to output" - cp "${ROOT}/babel.config.js" "${OUTPUT}babel.config.js" - - echo "✔️ package.json from root to output" - cp "${ROOT}/package.json" "${OUTPUT}package.json" - - echo "✔️ .npmrc from root to output" - cp "${ROOT}/.npmrc" "${OUTPUT}.npmrc" - - echo "" -fi - # Put together the path to the test results file result_file="${OUTPUT}results.json" echo "The results of this run will be written to 'results.json'." @@ -224,6 +170,9 @@ if test -f $configuration_file; then echo "" cat $configuration_file | jq -c '.files.test[]' | xargs -L 1 "$ROOT/bin/prepare.sh" ${OUTPUT} + + # Every exercise has one test file. + test_file=$(jq -r '.files.test[0]' "${configuration_file}") else if test -f $local_configuration_file; then echo "There is a configuration file in the .exercism local " @@ -234,6 +183,9 @@ else echo "" cat $local_configuration_file | jq -c '.files.test[]' | xargs -L 1 "$ROOT/bin/prepare.sh" ${OUTPUT} + + # Every exercise has one test file. + test_file=$(jq -r '.files.test[0]' "${local_configuration_file}") else test_file="${SLUG}.spec.js" @@ -254,7 +206,6 @@ else # Restore configuration files if test -f "${OUTPUT}babel.config.js.💥.bak"; then echo "✔️ restoring babel.config.js in output" - unlink "${OUTPUT}babel.config.js" mv "${OUTPUT}babel.config.js.💥.bak" "${OUTPUT}babel.config.js" || true fi; @@ -296,52 +247,6 @@ else fi fi -echo "" -echo "╔═════════════════════════════════════════════════════════════╗" -echo " 🔧 Preparing test project " -echo "╚═════════════════════════════════════════════════════════════╝" -echo "" - - -if test -f "${OUTPUT}package.json"; then - echo "✔️ standalone package found at ${OUTPUT}package.json" - echo "" - - if test -d "${OUTPUT}node_modules/.pnpm"; then - # echo "Found .pnpm hoisted packages" - # ls -aln1 "${OUTPUT}node_modules" - # echo "" - echo "Found .pnpm hoisted binaries" - else - echo ".pnpm hoisted packages not found" - cd "${COREPACK_ROOT_DIR}" && corepack pnpm install --offline --frozen-lockfile - fi -fi; - -# Call jest directly. Going through `corepack pnpm` started two extra -# Node processes (corepack, then pnpm) before jest itself. -bin_jest="${COREPACK_ROOT_DIR%/}/node_modules/.bin/jest" - -echo "👁️ ${COREPACK_ROOT_DIR} as corepack root" - -if [[ -f "${bin_jest}" ]]; then - echo "✔️ jest executable found using ${bin_jest}" - - if [[ -x "${bin_jest}" ]]; then - echo "✔️ jest executable is executable for $(whoami)" - else - echo "💥 jest executable not executable for $(whoami)" - - ls -l "${bin_jest}" - - exit -1 - fi -else - echo "💥 jest executable missing at ${bin_jest}" - exit -1 -fi; - - # Disable auto exit set +e @@ -351,36 +256,43 @@ echo " ➤ Execution (tests: does the solution work?) " echo "╚═════════════════════════════════════════════════════════════╝" echo "" -# Run tests. If Jest finds no test files, the reporter writes the "no tests" -# error to results.json. Checking for that here would mean starting Jest a -# second time (with --listTests) just to list the test files. -echo "⚙️ corepack pnpm jest <...>" -echo "" - -cd "${COREPACK_ROOT_DIR}" && "${bin_jest}" "${OUTPUT}*" \ - --bail 1 \ - --ci \ - --colors \ - --config ${CONFIG} \ - --noStackTrace \ - --outputFile="${result_file}" \ - --passWithNoTests \ - --reporters "${REPORTER}" \ - --roots "${OUTPUT}" \ - --setupFilesAfterEnv ${SETUP} \ - --verbose false \ - --testLocationInResults - -# Convert exit(1) (jest worked, but there are failing tests) to exit(0) -test_exit=$? +if test -f "${OUTPUT}${test_file}"; then + echo "⚙️ node --test ${test_file}" + echo "" -if [ $test_exit -eq 1 ]; then - echo "❌ not all tests (*.spec.js) passed." -elif grep -q "not subjected to any type or execution tests" "${result_file}"; then - # Jest found no test files, and the reporter wrote the "no tests" error. - echo "❌ no jest tests (*.spec.js) discovered." + # Run the tests with Node's built-in test runner. setup.mjs provides the + # Jest API the tests use, and reporter.mjs writes results.json. + # + # --test-isolation=none runs the test file in this process, instead of + # starting another one, and lets the reporter read the console messages. + # --test-force-exit stops the process once the tests have finished, even + # if the solution leaves a timer running. + # --experimental-test-module-mocks enables jest.mock (see setup.mts). + cd "${OUTPUT}" && TEST_FILE="${OUTPUT}${test_file}" RESULTS_FILE="${result_file}" node \ + --import "${SETUP}" \ + --experimental-test-module-mocks \ + --disable-warning=ExperimentalWarning \ + --test \ + --test-isolation=none \ + --test-force-exit \ + --test-reporter="${REPORTER}" \ + "${OUTPUT}${test_file}" + + # Convert exit(1) (the tests ran, but some failed) to exit(0) + test_exit=$? + + if [ $test_exit -eq 1 ]; then + echo "❌ not all tests (*.spec.js) passed." + else + echo "✅ all tests (*.spec.js) passed." + fi; else - echo "✅ all tests (*.spec.js) passed." + # The test file named in the configuration file is missing. + # Version 3 output can't have an empty list of tests, so this uses the + # version 1 format, which has no tests key. + test_exit=0 + echo "{ \"version\": 1, \"status\": \"error\", \"message\": \"The submitted code was not subjected to any type or execution tests. At least one test was expected.\" }" > "${result_file}" + echo "❌ no tests (*.spec.js) discovered." fi; echo "" @@ -391,7 +303,6 @@ echo "" # Restore configuration files if test -f "${OUTPUT}babel.config.js.💥.bak"; then echo "✔️ restoring babel.config.js in output" - unlink "${OUTPUT}babel.config.js" mv "${OUTPUT}babel.config.js.💥.bak" "${OUTPUT}babel.config.js" || true fi; diff --git a/eslint.config.mjs b/eslint.config.mjs index 06fbe46..355f39a 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -13,8 +13,6 @@ export default [ 'dist/**/*', 'test/fixtures/**/*', 'test_exercises/**/*', - 'babel.config.js', - 'jest.runner.config.js', ], }, ] diff --git a/jest.runner.config.js b/jest.runner.config.js deleted file mode 100644 index 101c492..0000000 --- a/jest.runner.config.js +++ /dev/null @@ -1,8 +0,0 @@ -module.exports = { - verbose: true, - modulePathIgnorePatterns: ['package.json'], - transform: { - '^.+\\.[t|j]sx?$': 'babel-jest', - }, - reporters: [], -} diff --git a/package.json b/package.json index 81a9948..3f6b244 100644 --- a/package.json +++ b/package.json @@ -27,21 +27,15 @@ "test:bare": "corepack pnpm node test/smoke.test.mjs && corepack pnpm node test/skip.test.mjs && corepack pnpm node test/log.test.mjs && corepack pnpm node test/taskid.test.mjs" }, "dependencies": { - "@exercism/babel-preset-javascript": "^0.7.0", - "@jest/console": "^30.4.0", - "@jest/reporters": "^30.4.0", - "@jest/test-result": "^30.4.0", - "@jest/types": "^30.4.0", + "@jest/console": "^30.5.2", "acorn": "^8.15.0", - "babel-jest": "^30.4.0", "chalk": "^6.0.0", - "core-js": "^3.44.0", - "jest": "^30.4.0", + "expect": "^30.5.2", + "jest-mock": "^30.5.2", "shelljs": "^0.10.0" }, "devDependencies": { "@exercism/eslint-config-tooling": "^0.9.0", - "@jest/globals": "^30.4.0", "@tsconfig/node22": "^22.0.2", "@types/node": "^22.16.5", "@types/shelljs": "^0.10.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9ec1202..c0c8590 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,36 +8,21 @@ importers: .: dependencies: - '@exercism/babel-preset-javascript': - specifier: ^0.7.0 - version: 0.7.0 '@jest/console': - specifier: ^30.4.0 + specifier: ^30.5.2 version: 30.5.2 - '@jest/reporters': - specifier: ^30.4.0 - version: 30.5.2 - '@jest/test-result': - specifier: ^30.4.0 - version: 30.5.2 - '@jest/types': - specifier: ^30.4.0 - version: 30.5.1 acorn: specifier: ^8.15.0 version: 8.15.0 - babel-jest: - specifier: ^30.4.0 - version: 30.5.2(@babel/core@7.29.7) chalk: specifier: ^6.0.0 version: 6.0.1 - core-js: - specifier: ^3.44.0 - version: 3.44.0 - jest: - specifier: ^30.4.0 - version: 30.5.2(@types/node@22.16.5) + expect: + specifier: ^30.5.2 + version: 30.5.2 + jest-mock: + specifier: ^30.5.2 + version: 30.5.2 shelljs: specifier: ^0.10.0 version: 0.10.0 @@ -45,9 +30,6 @@ importers: '@exercism/eslint-config-tooling': specifier: ^0.9.0 version: 0.9.0(@exercism/babel-preset-typescript@0.7.0)(@typescript-eslint/eslint-plugin@8.37.0(@typescript-eslint/parser@8.37.0(eslint@9.31.0)(typescript@5.7.3))(eslint@9.31.0)(typescript@5.7.3))(eslint@9.31.0)(jest@30.5.2(@types/node@22.16.5))(typescript@5.7.3) - '@jest/globals': - specifier: ^30.4.0 - version: 30.5.0 '@tsconfig/node22': specifier: ^22.0.2 version: 22.0.6 @@ -88,10 +70,6 @@ packages: resolution: {integrity: sha512-2W76mhjrpQFO1lK5e8IvGYB2D0YZ7S2R1Z2BjO2ZUYuW+amcpK/z60U6ZZmzskwoa7sJ6XohP/Wg8H5KxXI/IA==} engines: {node: '>=6.9.0'} - '@babel/generator@7.29.8': - resolution: {integrity: sha512-gZbepsdh3WDtgZKWL+vTPh71LSBrm/Y4/QDZBVCcYfmeTEEuoOYwlSy+G1StfJg+/Zy550u/3TATbm7qDbbMtg==} - engines: {node: '>=6.9.0'} - '@babel/helper-annotate-as-pure@7.29.7': resolution: {integrity: sha512-OoK6239jHPuSQOoS0kfTVKn0b/rVTk0seKq4Gd2UMLtmOVLjDC0ki3e+c90Trqv2gMfvJFqkiljrr568+qddiw==} engines: {node: '>=6.9.0'} @@ -106,12 +84,6 @@ packages: peerDependencies: '@babel/core': ^7.0.0 - '@babel/helper-create-class-features-plugin@7.29.7': - resolution: {integrity: sha512-IY3ZD9Tmooqr3TUhc3DUWxiuo8xx1DWLhd5M7hQ+ZWJamqM2BbalrBJb2MisSLoYorOj75U03qULCxQTY9r3hg==} - engines: {node: '>=6.9.0'} - peerDependencies: - '@babel/core': ^7.0.0 - '@babel/helper-create-regexp-features-plugin@7.29.7': resolution: {integrity: sha512-907Uymvqgg1dwUA+7IGwFAOSYzQOuzPXKNJ1yxzwPffzkYFg2q2eHi1fIOs6sXkG9NbIUMunnUlkYsfRFNvomg==} engines: {node: '>=6.9.0'} @@ -169,10 +141,6 @@ packages: resolution: {integrity: sha512-snZbO7MEDOof+hvNa97EjEY7qD7h2kwvQr5AJC3ZhQudKW5dnej6k3kP9NQV88hJwaS8vDqRLFo9rivLEhle2g==} engines: {node: '>=6.9.0'} - '@babel/helper-string-parser@7.29.7': - resolution: {integrity: sha512-Pb5ijPrZ89GDH8223L4UP8i6QApWxs04RbPQJTeWDV0/keR2E36MeKnyr6LYmUUvqRRI+Iv87SuF1W6ErINzYw==} - engines: {node: '>=6.9.0'} - '@babel/helper-validator-identifier@7.29.7': resolution: {integrity: sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==} engines: {node: '>=6.9.0'} @@ -201,16 +169,6 @@ packages: engines: {node: '>=6.0.0'} hasBin: true - '@babel/parser@7.29.8': - resolution: {integrity: sha512-E8lTAYNB1KW+FH+VGJuZM1ioAx2E6oVlvQFRrf5P8ZZmsiJXYAD9vTFV7yyEURNzgh1dFqMZuO6tUwcARbqFCA==} - engines: {node: '>=6.0.0'} - hasBin: true - - '@babel/parser@7.29.9': - resolution: {integrity: sha512-CjXrNHTnvqBVqHgdBysY3vk2T8tpJHb5/RMeHJBTyVa9xgugCB0CJTx/3oO8RV2QRQP391RWpB7D6hLjm8V9uA==} - engines: {node: '>=6.0.0'} - hasBin: true - '@babel/plugin-bugfix-firefox-class-in-computed-class-key@7.29.7': resolution: {integrity: sha512-j8SrR0zLZrRsC09DlszEx8FpMiwukKffYXMK0d5LmOglO7vGG6sz/BR/20yHqWH+Lnn31JTt2PE3hIWNgM2J6w==} engines: {node: '>=6.9.0'} @@ -699,18 +657,10 @@ packages: resolution: {integrity: sha512-MscXe/NAZcOkYEsRajHZFt3ynsb22PUi6CTrp5U7+RYycR9By84mn9mFN54YgfITiqK4hFx3Ju3tZSyzfpS5ew==} engines: {node: '>=6.9.0'} - '@babel/traverse@7.29.8': - resolution: {integrity: sha512-I5z7H3bf/41ktsNVLtpN0wAa336HkqIHQ5BuPLEhTkt1jVSyZpeNKIzTgEWmlxjdg81R0IgUCcaE+Ok3NvrfZg==} - engines: {node: '>=6.9.0'} - '@babel/types@7.29.11': resolution: {integrity: sha512-WCsemW40Cpc6gouC1SrY6PBaZ+oLRlEVY9XBvZBI7il/HyUrb2nJ505wE1MHEFyDZNnrWDEuy4jL50WVHfTTSQ==} engines: {node: '>=6.9.0'} - '@babel/types@7.29.8': - resolution: {integrity: sha512-Vj1jF3cPfxg7OAfoI7QnVKLoILlm2JF9pnVHrX8qx7AHMiYWT+NDAA7jChlNgRS4WTLc/fD1lXLmPixluj+3Gg==} - engines: {node: '>=6.9.0'} - '@bcoe/v8-coverage@0.2.3': resolution: {integrity: sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==} @@ -762,9 +712,6 @@ packages: resolution: {integrity: sha512-Ul5l+lHEcw3L5+k8POx6r74mxEYKG5kOb6Xpy2gCRW6zweT6TEhAf8vhxGgjhqrd/VO/Dirhsb+1hNpD1ue9hw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@exercism/babel-preset-javascript@0.7.0': - resolution: {integrity: sha512-232BssiG6xczvgnXdZkIW0UoWM1Cz9Hj7BAjgrQT01Qh3tETzQ95ofeSFL+gyJWScI7JhZuCQ4a+ybqYtQxTqg==} - '@exercism/babel-preset-typescript@0.7.0': resolution: {integrity: sha512-IHAc11nmiq/GVo2/Fps5HkMjXDOEux9BFQ36kQt3OOl78+1rDH3P+iJCsQ3xfWURBAODH/6m/YPw/0Wy4h+ZAw==} @@ -824,34 +771,18 @@ packages: resolution: {integrity: sha512-OsqBjHXCn8cadasoAZBP6nWYvMsRhpMzGXTpxJ5aO04NlbdhIz+FVe3q49l0AwVhsz/cEmIpBes6gAFl1/dWQg==} engines: {node: ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0} - '@jest/environment@30.5.0': - resolution: {integrity: sha512-HUaqexIauIh69IQ4NTuPDEUCB8g8T4TOPSIzQOS18mwI/KEHKQk1j013K2o6ra031szZE2t5jGmVx3xbzdjgKA==} - engines: {node: ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0} - '@jest/environment@30.5.2': resolution: {integrity: sha512-nwFPOUMbmsjNNRCpnJpB9HbSZu4C07wDDds++5j+j1MezzPLxMPDdbdUVjr2o4RULDOValnDd70taPFI1EtxAg==} engines: {node: ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0} - '@jest/expect-utils@30.5.0': - resolution: {integrity: sha512-5j0ztPxSy3McUJihjkDdCyCfjvT2hxykFTWsgEBZKB8qsw9ALdCiGTpTRH5gnf/d+qI4SflYUJ0dWNbzjQCWbA==} - engines: {node: ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0} - '@jest/expect-utils@30.5.2': resolution: {integrity: sha512-d/HOLSrJUlBIl6n3LzOa7cjW3xdePm5H5gQw2lixZ/0h157l9sw3mLblzFqnPcTbhDzhRQdBOX3A3KcG73nm5Q==} engines: {node: ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0} - '@jest/expect@30.5.0': - resolution: {integrity: sha512-jEmgmgJEobJ3zEhDOGp1VAJ6JkoVelpS8uZ1ae1Ul/5lP78UKJKmmU0lciJwd6JdnqOXHaaS/QCKwbf1dHI9MA==} - engines: {node: ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0} - '@jest/expect@30.5.2': resolution: {integrity: sha512-2E+1Pg6jJxbRjLNLpciC71iri/3qsKJL222/aXJEFwC0VdUSvfS+JZQQLEVjUYYc8t8pQu2MGE3cF2+bNTYRsg==} engines: {node: ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0} - '@jest/fake-timers@30.5.0': - resolution: {integrity: sha512-sg8xIbYwe5GdB/vT3/0qrDIpO7Ov9mazHi++M95uynmDKEZ70G1r169AWct73H07VrTZhrz1SJEfLtjYv8tE3A==} - engines: {node: ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0} - '@jest/fake-timers@30.5.2': resolution: {integrity: sha512-GKk0h0tKT5SpDPxDhPg3r9mm5s8/YCBzVNMOGdRiQXwUiMsjU10mVPlMaQstH6/cu50vOb8N9oQUMETHuwwxKw==} engines: {node: ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0} @@ -860,10 +791,6 @@ packages: resolution: {integrity: sha512-9/2VUPitAjmBzbvDvqrxmvB7BzWsBW0WmkkojX1ODuxX1NLGxx9gfaZpHB0z8DtJ9uhGNmZG/VXBhf8uO0OV8Q==} engines: {node: ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0} - '@jest/globals@30.5.0': - resolution: {integrity: sha512-h7eJx534czwL8lQMYB0hwLT4/HquO8EX/RtYL7RNUHyUyWWVciYjoudN4Ns5JmNvn2/jh0Vm9UstZjEzJJ5EsQ==} - engines: {node: ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0} - '@jest/globals@30.5.2': resolution: {integrity: sha512-62zfS+dL+M5aTNHXCNLyqD+j4oqxTIzDYrZbpqMP8Yn+gvlAGyzC6BSPNb1ZmFOakV1RtFYX/O3FCQXSWmQdgg==} engines: {node: ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0} @@ -885,10 +812,6 @@ packages: resolution: {integrity: sha512-/hunigyNpc4RCjC0VaW3f5RCUZVM2+WQ65qP7z083Gmvac7or2LI50XVNOtE4YPgBpV0yxYiAgorAPGniCoJmg==} engines: {node: ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0} - '@jest/snapshot-utils@30.5.0': - resolution: {integrity: sha512-iWQtIsi2dRsO2oWzVceOeynuRJiYTW8gsDVp5wFQ02ipHluQsNgBpasWSHiawVxukIlsGLdCtCSbIEK7fPtpvQ==} - engines: {node: ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0} - '@jest/snapshot-utils@30.5.1': resolution: {integrity: sha512-V3wnxNtiVmw5PPVg433Cn3VdXnsOeu/ofLw3KC04Bn2y1wIlU5kozXQn48rhrgj/02LrCVtntTEF1yBha0XSUw==} engines: {node: ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0} @@ -905,18 +828,10 @@ packages: resolution: {integrity: sha512-bmij8jZyYAC47ExT2GeP7PcrlwSNS+Bp3KeRuBH88gpcxqDv6fljN8PemS4J/lLZ79xb6mpaennQTTq0zUAVVg==} engines: {node: ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0} - '@jest/transform@30.5.0': - resolution: {integrity: sha512-n1cYhoByyULEIXi64wbT4Lq91qeT1E6bwpM//sprFXhw955qaiHTdAmy1c1rNFGB6fCf1J+nxDUSf3RGwgZP5A==} - engines: {node: ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0} - '@jest/transform@30.5.2': resolution: {integrity: sha512-LBGwmaE886C41jDZ65eqR1YbXM7642MK3ZhTowZd5+xDlrDLuf4ePuDdDmVSvcr8NTVJ3MqxLkMbUCzuigUaoQ==} engines: {node: ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0} - '@jest/types@30.5.0': - resolution: {integrity: sha512-s1N+79S4Yp9ZgklCauZXi+YPJdCdtStNYQT32stuD6EeQaIBGHoUfyj2P0YWy8RmuQfaJboO+ulxEvEheR/POQ==} - engines: {node: ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0} - '@jest/types@30.5.1': resolution: {integrity: sha512-LvVYn83nnXPl+Rg98nvcFgjx6nRMTArhSn6RAX/w3ELn54S8A42TYZvsCMdGUqTM8S0wyXbtlQdU6Hi6dykj9g==} engines: {node: ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0} @@ -1516,12 +1431,6 @@ packages: core-js@3.43.0: resolution: {integrity: sha512-N6wEbTTZSYOY2rYAn85CuvWWkCK6QweMn7/4Nr3w+gDBeBhk/x4EJeY6FPo4QzDoJZxVTv8U7CMvgWk6pOHHqA==} - core-js@3.44.0: - resolution: {integrity: sha512-aFCtd4l6GvAXwVEh3XbbVqJGHDJt0OZRa+5ePGx3LLwi12WfexqQxcsohb2wgsa/92xtl19Hd66G/L+TaAxDMw==} - - core-js@3.45.1: - resolution: {integrity: sha512-L4NPsJlCfZsPeXukyzHFlg/i7IIVwHSItR0wg0FLNqYClJ4MQYTYLbC7EkjKYRLZF2iof2MUgN0EGy7MdQFChg==} - core-js@3.49.0: resolution: {integrity: sha512-es1U2+YTtzpwkxVLwAFdSpaIMyQaq0PBgm3YD1W3Qpsn1NAmO3KSgZfu+oGSWVu6NvLHoHCV/aYcsE5wiB7ALg==} @@ -1738,10 +1647,6 @@ packages: resolution: {integrity: sha512-+I6B/IkJc1o/2tiURyz/ivu/O0nKNEArIUB5O7zBrlDVJr22SCLH3xTeEry428LvFhRzIA1g8izguxJ/gbNcVQ==} engines: {node: '>= 0.8.0'} - expect@30.5.0: - resolution: {integrity: sha512-8fiMWcEjPU7B9nErC4FtFcCzf2tC6I75Qf7m8wzBAWC2taZmcno3yAFEjIQL34SwoGZNgPf63UDiJLyh4SMPaw==} - engines: {node: ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0} - expect@30.5.2: resolution: {integrity: sha512-0LNuMvs8/5mRYhnCR4k+lGV7fqPMs6Bnksda4S3zsCUmdxBpAn4zU4NNzXdq1pMKe/H4W5t/zVIDSJ/H3e0vDA==} engines: {node: ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0} @@ -2150,10 +2055,6 @@ packages: ts-node: optional: true - jest-diff@30.5.0: - resolution: {integrity: sha512-QjCfDMwdPFvLxTQmS4/Dswx3PUCiqmSXVLGljMC3SU7YG1qHVoR6b86IH/O2G9k9OMyKXz2vS2Q60VnAozNDwA==} - engines: {node: ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0} - jest-diff@30.5.2: resolution: {integrity: sha512-rBtHnI6BWTiWj3lM7fOLVfChx7R9B0u9VV3PRHawKs79x6ZjW1QoSrKenaigNGWlvhtoi2BqvDbABDie+Os3xQ==} engines: {node: ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0} @@ -2170,10 +2071,6 @@ packages: resolution: {integrity: sha512-Ciz4KgTGIbojxSKpuFImgWJj5EyqfE8xMq9NxWmOXnQywHHS03H9Mv+vaCB29J5pr3JBrY27WbRV18rBdjh8Dg==} engines: {node: ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0} - jest-haste-map@30.5.0: - resolution: {integrity: sha512-0FStogBslBVOEqTOJr4oXMtFitmrWp9WscG6Gbns88i0YAuMXijCT2G5VMfg/HCR4QAnL+OF2C2ednag+HlDuA==} - engines: {node: ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0} - jest-haste-map@30.5.1: resolution: {integrity: sha512-VIFgt67jW480YDxKfEv9IYQKrFpYt7bOCMn3VsnjK7AK9qo7p6acpnA1DHwsVOULE3dTaYew/6JaTD/d0VDHoQ==} engines: {node: ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0} @@ -2182,26 +2079,14 @@ packages: resolution: {integrity: sha512-gt4GT2aWgEoCNTcBe4rqS74xTIUJxi+UD9SNSu9aOk5LmTEd6fS5KSTmAKAfitCCktQHNN+upUuL6EkBfFbMDQ==} engines: {node: ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0} - jest-matcher-utils@30.5.0: - resolution: {integrity: sha512-EfaYMC9f9ds7fahB/LYFTgd1Z2RS9Vpm2e46gazij0onkpoQG7Daq+MLm8/gQVqWwRVjL/RNDggbFx9MsrJEmQ==} - engines: {node: ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0} - jest-matcher-utils@30.5.2: resolution: {integrity: sha512-lFkB365PTIHOhPzwrb9T6gvlDnPpOZ7/c3ewOKKB7bzztqjVrtlyRL2MkyfJXpyY2u2SKw001JKrTx14fBUFcQ==} engines: {node: ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0} - jest-message-util@30.5.0: - resolution: {integrity: sha512-dBYMhplGfspKaCnVk9TUy1cZnknWubpuPNEputjz0YJk1G/92R45rn45BvbPMPMtC5LVcIdxJGPOaOSQTiuzJw==} - engines: {node: ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0} - jest-message-util@30.5.1: resolution: {integrity: sha512-UdQlLdd9wL/Ys7xRErckqwD6wPlSZYueosSWuHc1r2ztGLwlgPvtSJq2+BPEgaEY13WLvfFbmhTj8pba0Sd1jg==} engines: {node: ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0} - jest-mock@30.5.0: - resolution: {integrity: sha512-bP5MHZpkYrV7xpV+yvhl36DPcXoEmTR57Un5EACcdVpMY7mpkDefCBq+V4mhcjE/3rwUajT6OTrcJTN7EwN1BA==} - engines: {node: ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0} - jest-mock@30.5.2: resolution: {integrity: sha512-KTHb37Fhj8xY8qPFvTFaFJHcdsumQp+ExsUlgoX232Agmc706gagBs53+CYvulV7MVQo9AgXOUxsqzzVBoJlrA==} engines: {node: ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0} @@ -2226,18 +2111,10 @@ packages: resolution: {integrity: sha512-0paUAHBlheai10A3XSy9Xh+YBG0IROy+/qzcDPzQ/nbbXrznQzeWy5qniICWK6d3W3scaRQCVAbXdcK0ibBq4w==} engines: {node: ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0} - jest-snapshot@30.5.0: - resolution: {integrity: sha512-pZWETdcqmKve9MDTE/AX6RaeAbRhzKhhAXGozAW8Pg2FfOSdUrQ/7D+VdwE3fLQsqjpITXJVQvYVZoMEzrUl0Q==} - engines: {node: ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0} - jest-snapshot@30.5.2: resolution: {integrity: sha512-jKIdes25AnAH73dOCi2qE6J6vHJ6L2vyBS11M89kT50DVJcLTf2AOjvcc+2vVaN8lUbY5v2R83aqXo3Ro9fqYA==} engines: {node: ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0} - jest-util@30.5.0: - resolution: {integrity: sha512-lzU4aGUWaS+2X/B0CmgheDasfnsVlRfZh/rNQxB9b9s8cSYUq5BcqdQA95ld+KqJXBUVVt1sqnMQ2T3OxIalmg==} - engines: {node: ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0} - jest-util@30.5.1: resolution: {integrity: sha512-yKuxmNy2rSbTXw+3SIPanJo+nV4/BS1p26v44IYBFMsswSQySfMMcPHErnOncda7i9HEz0q605rIhSTBVgrZTg==} engines: {node: ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0} @@ -2250,10 +2127,6 @@ packages: resolution: {integrity: sha512-rqRgg4R11GA9m1UsEZwQeixHsgZReCn6TOHAHtIH33yXrIvoX0OGPA20Yzzjkz7X40fZvcRSxEpQppYPcWzmcQ==} engines: {node: ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0} - jest-worker@30.5.0: - resolution: {integrity: sha512-7kFk/607EoynNHLJa20daivkElM+c9PrCLduYy6AlMkYrXbh5TmVtW1BLXE05Y8baAFsJHMoC3xs2QRRTotwLw==} - engines: {node: ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0} - jest-worker@30.5.1: resolution: {integrity: sha512-Cbxh5v7AoLuFRmFJSM4/aHdQ68rjXvUWr716EE0Dh3I7T+T/3FgFKhOERGXHcU2Meftq9+9zxPM3TSNyI9D+HA==} engines: {node: ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0} @@ -2555,10 +2428,6 @@ packages: engines: {node: '>=14'} hasBin: true - pretty-format@30.5.0: - resolution: {integrity: sha512-mzNzBErpHwM0zpmWS7ExOv62yhQhvd546nUuFqVR0dmnJB59tfrw9sjDF0DJknwsr59OXP0buwJ7PaKguczHSg==} - engines: {node: ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0} - pretty-format@30.5.1: resolution: {integrity: sha512-byhRAPguVKMQIj4kjJwJ5lAskVhfuiSdiYl/aLTWpgkGEmic2jYhJh1yE9ih8Ox44Xg9ccCT11/S6QrzSJuNrg==} engines: {node: ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0} @@ -2971,14 +2840,14 @@ snapshots: '@babel/core@7.29.7': dependencies: '@babel/code-frame': 7.29.7 - '@babel/generator': 7.29.8 + '@babel/generator': 7.29.12 '@babel/helper-compilation-targets': 7.29.7 '@babel/helper-module-transforms': 7.29.7(@babel/core@7.29.7) '@babel/helpers': 7.29.7 - '@babel/parser': 7.29.8 + '@babel/parser': 7.29.12 '@babel/template': 7.29.7 - '@babel/traverse': 7.29.8 - '@babel/types': 7.29.8 + '@babel/traverse': 7.29.12 + '@babel/types': 7.29.11 '@jridgewell/remapping': 2.3.5 convert-source-map: 2.0.0 debug: 4.4.3 @@ -2996,14 +2865,6 @@ snapshots: '@jridgewell/trace-mapping': 0.3.31 jsesc: 3.1.0 - '@babel/generator@7.29.8': - dependencies: - '@babel/parser': 7.29.8 - '@babel/types': 7.29.8 - '@jridgewell/gen-mapping': 0.3.13 - '@jridgewell/trace-mapping': 0.3.31 - jsesc: 3.1.0 - '@babel/helper-annotate-as-pure@7.29.7': dependencies: '@babel/types': 7.29.11 @@ -3029,19 +2890,6 @@ snapshots: transitivePeerDependencies: - supports-color - '@babel/helper-create-class-features-plugin@7.29.7(@babel/core@7.29.7)': - dependencies: - '@babel/core': 7.29.7 - '@babel/helper-annotate-as-pure': 7.29.7 - '@babel/helper-member-expression-to-functions': 7.29.7 - '@babel/helper-optimise-call-expression': 7.29.7 - '@babel/helper-replace-supers': 7.29.7(@babel/core@7.29.7) - '@babel/helper-skip-transparent-expression-wrappers': 7.29.7 - '@babel/traverse': 7.29.8 - semver: 6.3.1 - transitivePeerDependencies: - - supports-color - '@babel/helper-create-regexp-features-plugin@7.29.7(@babel/core@7.29.7)': dependencies: '@babel/core': 7.29.7 @@ -3064,15 +2912,15 @@ snapshots: '@babel/helper-member-expression-to-functions@7.29.7': dependencies: - '@babel/traverse': 7.29.8 + '@babel/traverse': 7.29.12 '@babel/types': 7.29.11 transitivePeerDependencies: - supports-color '@babel/helper-module-imports@7.29.7': dependencies: - '@babel/traverse': 7.29.8 - '@babel/types': 7.29.8 + '@babel/traverse': 7.29.12 + '@babel/types': 7.29.11 transitivePeerDependencies: - supports-color @@ -3081,7 +2929,7 @@ snapshots: '@babel/core': 7.29.7 '@babel/helper-module-imports': 7.29.7 '@babel/helper-validator-identifier': 7.29.7 - '@babel/traverse': 7.29.8 + '@babel/traverse': 7.29.12 transitivePeerDependencies: - supports-color @@ -3096,7 +2944,7 @@ snapshots: '@babel/core': 7.29.7 '@babel/helper-annotate-as-pure': 7.29.7 '@babel/helper-wrap-function': 7.29.7 - '@babel/traverse': 7.29.8 + '@babel/traverse': 7.29.12 transitivePeerDependencies: - supports-color @@ -3105,21 +2953,19 @@ snapshots: '@babel/core': 7.29.7 '@babel/helper-member-expression-to-functions': 7.29.7 '@babel/helper-optimise-call-expression': 7.29.7 - '@babel/traverse': 7.29.8 + '@babel/traverse': 7.29.12 transitivePeerDependencies: - supports-color '@babel/helper-skip-transparent-expression-wrappers@7.29.7': dependencies: - '@babel/traverse': 7.29.8 + '@babel/traverse': 7.29.12 '@babel/types': 7.29.11 transitivePeerDependencies: - supports-color '@babel/helper-string-parser@7.29.11': {} - '@babel/helper-string-parser@7.29.7': {} - '@babel/helper-validator-identifier@7.29.7': {} '@babel/helper-validator-option@7.29.7': {} @@ -3127,7 +2973,7 @@ snapshots: '@babel/helper-wrap-function@7.29.7': dependencies: '@babel/template': 7.29.7 - '@babel/traverse': 7.29.8 + '@babel/traverse': 7.29.12 '@babel/types': 7.29.11 transitivePeerDependencies: - supports-color @@ -3135,7 +2981,7 @@ snapshots: '@babel/helpers@7.29.7': dependencies: '@babel/template': 7.29.7 - '@babel/types': 7.29.8 + '@babel/types': 7.29.11 '@babel/node@7.29.7(@babel/core@7.29.7)': dependencies: @@ -3151,19 +2997,11 @@ snapshots: dependencies: '@babel/types': 7.29.11 - '@babel/parser@7.29.8': - dependencies: - '@babel/types': 7.29.8 - - '@babel/parser@7.29.9': - dependencies: - '@babel/types': 7.29.11 - '@babel/plugin-bugfix-firefox-class-in-computed-class-key@7.29.7(@babel/core@7.29.7)': dependencies: '@babel/core': 7.29.7 '@babel/helper-plugin-utils': 7.29.7 - '@babel/traverse': 7.29.8 + '@babel/traverse': 7.29.12 transitivePeerDependencies: - supports-color @@ -3198,7 +3036,7 @@ snapshots: dependencies: '@babel/core': 7.29.7 '@babel/helper-plugin-utils': 7.29.7 - '@babel/traverse': 7.29.8 + '@babel/traverse': 7.29.12 transitivePeerDependencies: - supports-color @@ -3210,21 +3048,25 @@ snapshots: dependencies: '@babel/core': 7.29.7 '@babel/helper-plugin-utils': 7.29.7 + optional: true '@babel/plugin-syntax-bigint@7.8.3(@babel/core@7.29.7)': dependencies: '@babel/core': 7.29.7 '@babel/helper-plugin-utils': 7.29.7 + optional: true '@babel/plugin-syntax-class-properties@7.12.13(@babel/core@7.29.7)': dependencies: '@babel/core': 7.29.7 '@babel/helper-plugin-utils': 7.29.7 + optional: true '@babel/plugin-syntax-class-static-block@7.14.5(@babel/core@7.29.7)': dependencies: '@babel/core': 7.29.7 '@babel/helper-plugin-utils': 7.29.7 + optional: true '@babel/plugin-syntax-import-assertions@7.29.7(@babel/core@7.29.7)': dependencies: @@ -3240,11 +3082,13 @@ snapshots: dependencies: '@babel/core': 7.29.7 '@babel/helper-plugin-utils': 7.29.7 + optional: true '@babel/plugin-syntax-json-strings@7.8.3(@babel/core@7.29.7)': dependencies: '@babel/core': 7.29.7 '@babel/helper-plugin-utils': 7.29.7 + optional: true '@babel/plugin-syntax-jsx@7.29.7(@babel/core@7.29.7)': dependencies: @@ -3255,41 +3099,49 @@ snapshots: dependencies: '@babel/core': 7.29.7 '@babel/helper-plugin-utils': 7.29.7 + optional: true '@babel/plugin-syntax-nullish-coalescing-operator@7.8.3(@babel/core@7.29.7)': dependencies: '@babel/core': 7.29.7 '@babel/helper-plugin-utils': 7.29.7 + optional: true '@babel/plugin-syntax-numeric-separator@7.10.4(@babel/core@7.29.7)': dependencies: '@babel/core': 7.29.7 '@babel/helper-plugin-utils': 7.29.7 + optional: true '@babel/plugin-syntax-object-rest-spread@7.8.3(@babel/core@7.29.7)': dependencies: '@babel/core': 7.29.7 '@babel/helper-plugin-utils': 7.29.7 + optional: true '@babel/plugin-syntax-optional-catch-binding@7.8.3(@babel/core@7.29.7)': dependencies: '@babel/core': 7.29.7 '@babel/helper-plugin-utils': 7.29.7 + optional: true '@babel/plugin-syntax-optional-chaining@7.8.3(@babel/core@7.29.7)': dependencies: '@babel/core': 7.29.7 '@babel/helper-plugin-utils': 7.29.7 + optional: true '@babel/plugin-syntax-private-property-in-object@7.14.5(@babel/core@7.29.7)': dependencies: '@babel/core': 7.29.7 '@babel/helper-plugin-utils': 7.29.7 + optional: true '@babel/plugin-syntax-top-level-await@7.14.5(@babel/core@7.29.7)': dependencies: '@babel/core': 7.29.7 '@babel/helper-plugin-utils': 7.29.7 + optional: true '@babel/plugin-syntax-typescript@7.29.7(@babel/core@7.29.7)': dependencies: @@ -3312,7 +3164,7 @@ snapshots: '@babel/core': 7.29.7 '@babel/helper-plugin-utils': 7.29.7 '@babel/helper-remap-async-to-generator': 7.29.7(@babel/core@7.29.7) - '@babel/traverse': 7.29.8 + '@babel/traverse': 7.29.12 transitivePeerDependencies: - supports-color @@ -3338,7 +3190,7 @@ snapshots: '@babel/plugin-transform-class-properties@7.29.7(@babel/core@7.29.7)': dependencies: '@babel/core': 7.29.7 - '@babel/helper-create-class-features-plugin': 7.29.7(@babel/core@7.29.7) + '@babel/helper-create-class-features-plugin': 7.29.12(@babel/core@7.29.7) '@babel/helper-plugin-utils': 7.29.7 transitivePeerDependencies: - supports-color @@ -3346,7 +3198,7 @@ snapshots: '@babel/plugin-transform-class-static-block@7.29.7(@babel/core@7.29.7)': dependencies: '@babel/core': 7.29.7 - '@babel/helper-create-class-features-plugin': 7.29.7(@babel/core@7.29.7) + '@babel/helper-create-class-features-plugin': 7.29.12(@babel/core@7.29.7) '@babel/helper-plugin-utils': 7.29.7 transitivePeerDependencies: - supports-color @@ -3359,7 +3211,7 @@ snapshots: '@babel/helper-globals': 7.29.7 '@babel/helper-plugin-utils': 7.29.7 '@babel/helper-replace-supers': 7.29.7(@babel/core@7.29.7) - '@babel/traverse': 7.29.8 + '@babel/traverse': 7.29.12 transitivePeerDependencies: - supports-color @@ -3373,7 +3225,7 @@ snapshots: dependencies: '@babel/core': 7.29.7 '@babel/helper-plugin-utils': 7.29.7 - '@babel/traverse': 7.29.8 + '@babel/traverse': 7.29.12 transitivePeerDependencies: - supports-color @@ -3430,7 +3282,7 @@ snapshots: '@babel/core': 7.29.7 '@babel/helper-compilation-targets': 7.29.7 '@babel/helper-plugin-utils': 7.29.7 - '@babel/traverse': 7.29.8 + '@babel/traverse': 7.29.12 transitivePeerDependencies: - supports-color @@ -3476,7 +3328,7 @@ snapshots: '@babel/helper-module-transforms': 7.29.7(@babel/core@7.29.7) '@babel/helper-plugin-utils': 7.29.7 '@babel/helper-validator-identifier': 7.29.7 - '@babel/traverse': 7.29.8 + '@babel/traverse': 7.29.12 transitivePeerDependencies: - supports-color @@ -3516,7 +3368,7 @@ snapshots: '@babel/helper-plugin-utils': 7.29.7 '@babel/plugin-transform-destructuring': 7.29.7(@babel/core@7.29.7) '@babel/plugin-transform-parameters': 7.29.7(@babel/core@7.29.7) - '@babel/traverse': 7.29.8 + '@babel/traverse': 7.29.12 transitivePeerDependencies: - supports-color @@ -3549,7 +3401,7 @@ snapshots: '@babel/plugin-transform-private-methods@7.29.7(@babel/core@7.29.7)': dependencies: '@babel/core': 7.29.7 - '@babel/helper-create-class-features-plugin': 7.29.7(@babel/core@7.29.7) + '@babel/helper-create-class-features-plugin': 7.29.12(@babel/core@7.29.7) '@babel/helper-plugin-utils': 7.29.7 transitivePeerDependencies: - supports-color @@ -3558,7 +3410,7 @@ snapshots: dependencies: '@babel/core': 7.29.7 '@babel/helper-annotate-as-pure': 7.29.7 - '@babel/helper-create-class-features-plugin': 7.29.7(@babel/core@7.29.7) + '@babel/helper-create-class-features-plugin': 7.29.12(@babel/core@7.29.7) '@babel/helper-plugin-utils': 7.29.7 transitivePeerDependencies: - supports-color @@ -3753,8 +3605,8 @@ snapshots: '@babel/template@7.29.7': dependencies: '@babel/code-frame': 7.29.7 - '@babel/parser': 7.29.8 - '@babel/types': 7.29.8 + '@babel/parser': 7.29.12 + '@babel/types': 7.29.11 '@babel/traverse@7.29.12': dependencies: @@ -3768,29 +3620,13 @@ snapshots: transitivePeerDependencies: - supports-color - '@babel/traverse@7.29.8': - dependencies: - '@babel/code-frame': 7.29.7 - '@babel/generator': 7.29.8 - '@babel/helper-globals': 7.29.7 - '@babel/parser': 7.29.8 - '@babel/template': 7.29.7 - '@babel/types': 7.29.8 - debug: 4.4.3 - transitivePeerDependencies: - - supports-color - '@babel/types@7.29.11': dependencies: '@babel/helper-string-parser': 7.29.11 '@babel/helper-validator-identifier': 7.29.7 - '@babel/types@7.29.8': - dependencies: - '@babel/helper-string-parser': 7.29.7 - '@babel/helper-validator-identifier': 7.29.7 - - '@bcoe/v8-coverage@0.2.3': {} + '@bcoe/v8-coverage@0.2.3': + optional: true '@eslint-community/eslint-utils@4.4.0(eslint@9.31.0)': dependencies: @@ -3843,15 +3679,6 @@ snapshots: '@eslint/core': 0.15.1 levn: 0.4.1 - '@exercism/babel-preset-javascript@0.7.0': - dependencies: - '@babel/core': 7.29.7 - '@babel/node': 7.29.7(@babel/core@7.29.7) - '@babel/preset-env': 7.29.7(@babel/core@7.29.7) - core-js: 3.45.1 - transitivePeerDependencies: - - supports-color - '@exercism/babel-preset-typescript@0.7.0': dependencies: '@babel/core': 7.29.7 @@ -3898,6 +3725,7 @@ snapshots: strip-ansi-cjs: strip-ansi@6.0.1 wrap-ansi: 8.1.0 wrap-ansi-cjs: wrap-ansi@7.0.0 + optional: true '@istanbuljs/load-nyc-config@1.1.0': dependencies: @@ -3906,8 +3734,10 @@ snapshots: get-package-type: 0.1.0 js-yaml: 3.15.2 resolve-from: 5.0.0 + optional: true - '@istanbuljs/schema@0.1.6': {} + '@istanbuljs/schema@0.1.6': + optional: true '@jest/console@30.5.2': dependencies: @@ -3953,53 +3783,29 @@ snapshots: - esbuild-register - supports-color - ts-node + optional: true '@jest/diff-sequences@30.5.0': {} - '@jest/environment@30.5.0': - dependencies: - '@jest/fake-timers': 30.5.0 - '@jest/types': 30.5.0 - '@types/node': 22.16.5 - jest-mock: 30.5.0 - '@jest/environment@30.5.2': dependencies: '@jest/fake-timers': 30.5.2 '@jest/types': 30.5.1 '@types/node': 22.16.5 jest-mock: 30.5.2 - - '@jest/expect-utils@30.5.0': - dependencies: - '@jest/get-type': 30.5.0 + optional: true '@jest/expect-utils@30.5.2': dependencies: '@jest/get-type': 30.5.0 - '@jest/expect@30.5.0': - dependencies: - expect: 30.5.0 - jest-snapshot: 30.5.0 - transitivePeerDependencies: - - supports-color - '@jest/expect@30.5.2': dependencies: expect: 30.5.2 jest-snapshot: 30.5.2 transitivePeerDependencies: - supports-color - - '@jest/fake-timers@30.5.0': - dependencies: - '@jest/types': 30.5.0 - '@sinonjs/fake-timers': 15.4.0 - '@types/node': 22.16.5 - jest-message-util: 30.5.0 - jest-mock: 30.5.0 - jest-util: 30.5.0 + optional: true '@jest/fake-timers@30.5.2': dependencies: @@ -4009,18 +3815,10 @@ snapshots: jest-message-util: 30.5.1 jest-mock: 30.5.2 jest-util: 30.5.1 + optional: true '@jest/get-type@30.5.0': {} - '@jest/globals@30.5.0': - dependencies: - '@jest/environment': 30.5.0 - '@jest/expect': 30.5.0 - '@jest/types': 30.5.0 - jest-mock: 30.5.0 - transitivePeerDependencies: - - supports-color - '@jest/globals@30.5.2': dependencies: '@jest/environment': 30.5.2 @@ -4029,6 +3827,7 @@ snapshots: jest-mock: 30.5.2 transitivePeerDependencies: - supports-color + optional: true '@jest/pattern@30.5.0': dependencies: @@ -4062,24 +3861,19 @@ snapshots: v8-to-istanbul: 9.3.0 transitivePeerDependencies: - supports-color + optional: true '@jest/schemas@30.5.0': dependencies: '@sinclair/typebox': 0.34.52 - '@jest/snapshot-utils@30.5.0': - dependencies: - '@jest/types': 30.5.0 - chalk: 4.1.2 - graceful-fs: 4.2.11 - natural-compare: 1.4.0 - '@jest/snapshot-utils@30.5.1': dependencies: '@jest/types': 30.5.1 chalk: 4.1.2 graceful-fs: 4.2.11 natural-compare: 1.4.0 + optional: true '@jest/source-map@30.5.2': dependencies: @@ -4087,6 +3881,7 @@ snapshots: callsites: 3.1.0 convert-source-map: 2.0.0 graceful-fs: 4.2.11 + optional: true '@jest/test-result@30.5.2': dependencies: @@ -4094,6 +3889,7 @@ snapshots: '@jest/types': 30.5.1 '@types/istanbul-lib-coverage': 2.0.6 collect-v8-coverage: 1.0.3 + optional: true '@jest/test-sequencer@30.5.2': dependencies: @@ -4101,25 +3897,7 @@ snapshots: graceful-fs: 4.2.11 jest-haste-map: 30.5.1 slash: 3.0.0 - - '@jest/transform@30.5.0': - dependencies: - '@babel/core': 7.29.7 - '@jest/types': 30.5.0 - '@jridgewell/trace-mapping': 0.3.31 - babel-plugin-istanbul: 8.0.0 - chalk: 4.1.2 - convert-source-map: 2.0.0 - fast-json-stable-stringify: 2.1.0 - graceful-fs: 4.2.11 - jest-haste-map: 30.5.0 - jest-regex-util: 30.5.0 - jest-util: 30.5.0 - pirates: 4.0.7 - slash: 3.0.0 - write-file-atomic: 5.0.1 - transitivePeerDependencies: - - supports-color + optional: true '@jest/transform@30.5.2': dependencies: @@ -4139,16 +3917,7 @@ snapshots: write-file-atomic: 5.0.1 transitivePeerDependencies: - supports-color - - '@jest/types@30.5.0': - dependencies: - '@jest/pattern': 30.5.0 - '@jest/schemas': 30.5.0 - '@types/istanbul-lib-coverage': 2.0.6 - '@types/istanbul-reports': 3.0.4 - '@types/node': 22.16.5 - '@types/yargs': 17.0.35 - chalk: 4.1.2 + optional: true '@jest/types@30.5.1': dependencies: @@ -4246,21 +4015,25 @@ snapshots: '@parcel/watcher-linux-x64-musl': 2.6.0 '@parcel/watcher-win32-arm64': 2.6.0 '@parcel/watcher-win32-x64': 2.6.0 + optional: true '@pkgjs/parseargs@0.11.0': optional: true - '@pkgr/core@0.3.6': {} + '@pkgr/core@0.3.6': + optional: true '@sinclair/typebox@0.34.52': {} '@sinonjs/commons@3.0.1': dependencies: type-detect: 4.0.8 + optional: true '@sinonjs/fake-timers@15.4.0': dependencies: '@sinonjs/commons': 3.0.1 + optional: true '@tsconfig/node22@22.0.6': {} @@ -4271,19 +4044,23 @@ snapshots: '@types/babel__generator': 7.27.0 '@types/babel__template': 7.4.4 '@types/babel__traverse': 7.28.0 + optional: true '@types/babel__generator@7.27.0': dependencies: '@babel/types': 7.29.11 + optional: true '@types/babel__template@7.4.4': dependencies: '@babel/parser': 7.29.12 '@babel/types': 7.29.11 + optional: true '@types/babel__traverse@7.28.0': dependencies: '@babel/types': 7.29.11 + optional: true '@types/estree@1.0.8': {} @@ -4447,7 +4224,8 @@ snapshots: '@typescript-eslint/types': 8.37.0 eslint-visitor-keys: 4.2.1 - '@ungap/structured-clone@1.4.0': {} + '@ungap/structured-clone@1.4.0': + optional: true '@unrs/resolver-binding-android-arm-eabi@1.13.0': optional: true @@ -4528,10 +4306,13 @@ snapshots: ansi-escapes@4.3.2: dependencies: type-fest: 0.21.3 + optional: true - ansi-regex@5.0.1: {} + ansi-regex@5.0.1: + optional: true - ansi-regex@6.5.0: {} + ansi-regex@6.5.0: + optional: true ansi-styles@4.3.0: dependencies: @@ -4539,16 +4320,19 @@ snapshots: ansi-styles@5.2.0: {} - ansi-styles@6.2.3: {} + ansi-styles@6.2.3: + optional: true anymatch@3.1.3: dependencies: normalize-path: 3.0.0 picomatch: 2.3.2 + optional: true argparse@1.0.10: dependencies: sprintf-js: 1.0.3 + optional: true argparse@2.0.1: {} @@ -4598,6 +4382,7 @@ snapshots: slash: 3.0.0 transitivePeerDependencies: - supports-color + optional: true babel-plugin-istanbul@8.0.0: dependencies: @@ -4608,10 +4393,12 @@ snapshots: test-exclude: 7.0.2 transitivePeerDependencies: - supports-color + optional: true babel-plugin-jest-hoist@30.5.0: dependencies: '@types/babel__core': 7.20.5 + optional: true babel-plugin-polyfill-corejs2@0.4.17(@babel/core@7.29.7): dependencies: @@ -4655,12 +4442,14 @@ snapshots: '@babel/plugin-syntax-optional-chaining': 7.8.3(@babel/core@7.29.7) '@babel/plugin-syntax-private-property-in-object': 7.14.5(@babel/core@7.29.7) '@babel/plugin-syntax-top-level-await': 7.14.5(@babel/core@7.29.7) + optional: true babel-preset-jest@30.5.0(@babel/core@7.29.7): dependencies: '@babel/core': 7.29.7 babel-plugin-jest-hoist: 30.5.0 babel-preset-current-node-syntax: 1.2.0(@babel/core@7.29.7) + optional: true balanced-match@1.0.2: {} @@ -4696,6 +4485,7 @@ snapshots: bser@2.1.2: dependencies: node-int64: 0.4.0 + optional: true buffer-from@1.1.2: {} @@ -4718,9 +4508,11 @@ snapshots: callsites@3.1.0: {} - camelcase@5.3.1: {} + camelcase@5.3.1: + optional: true - camelcase@6.3.0: {} + camelcase@6.3.0: + optional: true caniuse-lite@1.0.30001806: {} @@ -4731,17 +4523,20 @@ snapshots: chalk@6.0.1: {} - char-regex@1.0.2: {} + char-regex@1.0.2: + optional: true ci-info@4.4.0: {} - cjs-module-lexer@2.3.0: {} + cjs-module-lexer@2.3.0: + optional: true cliui@8.0.1: dependencies: string-width: 4.2.3 strip-ansi: 6.0.1 wrap-ansi: 7.0.0 + optional: true clone-deep@4.0.1: dependencies: @@ -4749,9 +4544,11 @@ snapshots: kind-of: 6.0.3 shallow-clone: 3.0.1 - co@4.6.0: {} + co@4.6.0: + optional: true - collect-v8-coverage@1.0.3: {} + collect-v8-coverage@1.0.3: + optional: true color-convert@2.0.1: dependencies: @@ -4773,10 +4570,6 @@ snapshots: core-js@3.43.0: {} - core-js@3.44.0: {} - - core-js@3.45.1: {} - core-js@3.49.0: {} cross-spawn@7.0.6: @@ -4811,11 +4604,13 @@ snapshots: dependencies: ms: 2.1.3 - dedent@1.7.2: {} + dedent@1.7.2: + optional: true deep-is@0.1.4: {} - deepmerge@4.3.1: {} + deepmerge@4.3.1: + optional: true define-data-property@1.1.4: dependencies: @@ -4829,9 +4624,11 @@ snapshots: has-property-descriptors: 1.0.2 object-keys: 1.1.1 - detect-libc@2.1.2: {} + detect-libc@2.1.2: + optional: true - detect-newline@3.1.0: {} + detect-newline@3.1.0: + optional: true dir-glob@3.0.1: dependencies: @@ -4843,19 +4640,24 @@ snapshots: es-errors: 1.3.0 gopd: 1.2.0 - eastasianwidth@0.2.0: {} + eastasianwidth@0.2.0: + optional: true electron-to-chromium@1.5.399: {} - emittery@0.13.1: {} + emittery@0.13.1: + optional: true - emoji-regex@8.0.0: {} + emoji-regex@8.0.0: + optional: true - emoji-regex@9.2.2: {} + emoji-regex@9.2.2: + optional: true error-ex@1.3.4: dependencies: is-arrayish: 0.2.1 + optional: true es-abstract-get@1.0.0: dependencies: @@ -4927,7 +4729,8 @@ snapshots: es-errors@1.3.0: {} - es-module-lexer@2.3.2: {} + es-module-lexer@2.3.2: + optional: true es-object-atoms@1.1.2: dependencies: @@ -5025,7 +4828,8 @@ snapshots: acorn-jsx: 5.3.2(acorn@8.15.0) eslint-visitor-keys: 4.2.1 - esprima@4.0.1: {} + esprima@4.0.1: + optional: true esquery@1.6.0: dependencies: @@ -5051,16 +4855,8 @@ snapshots: signal-exit: 3.0.7 strip-final-newline: 2.0.0 - exit-x@0.2.2: {} - - expect@30.5.0: - dependencies: - '@jest/expect-utils': 30.5.0 - '@jest/get-type': 30.5.0 - jest-matcher-utils: 30.5.0 - jest-message-util: 30.5.0 - jest-mock: 30.5.0 - jest-util: 30.5.0 + exit-x@0.2.2: + optional: true expect@30.5.2: dependencies: @@ -5092,10 +4888,12 @@ snapshots: fb-watchman@2.0.4: dependencies: bser: 2.1.2 + optional: true fdir@6.5.0(picomatch@4.0.7): optionalDependencies: picomatch: 4.0.7 + optional: true file-entry-cache@8.0.0: dependencies: @@ -5119,6 +4917,7 @@ snapshots: dependencies: locate-path: 5.0.0 path-exists: 4.0.0 + optional: true find-up@5.0.0: dependencies: @@ -5140,6 +4939,7 @@ snapshots: dependencies: cross-spawn: 7.0.6 signal-exit: 4.1.0 + optional: true function-bind@1.1.2: {} @@ -5161,7 +4961,8 @@ snapshots: gensync@1.0.0-beta.2: {} - get-caller-file@2.0.5: {} + get-caller-file@2.0.5: + optional: true get-intrinsic@1.3.0: dependencies: @@ -5176,7 +4977,8 @@ snapshots: hasown: 2.0.4 math-intrinsics: 1.1.0 - get-package-type@0.1.0: {} + get-package-type@0.1.0: + optional: true get-proto@1.0.1: dependencies: @@ -5207,6 +5009,7 @@ snapshots: minipass: 7.1.3 package-json-from-dist: 1.0.1 path-scurry: 1.11.1 + optional: true glob@13.0.6: dependencies: @@ -5264,7 +5067,8 @@ snapshots: dependencies: parse-passwd: 1.0.0 - html-escaper@2.0.2: {} + html-escaper@2.0.2: + optional: true human-signals@2.1.0: {} @@ -5281,6 +5085,7 @@ snapshots: dependencies: pkg-dir: 4.2.0 resolve-cwd: 3.0.0 + optional: true imurmurhash@0.1.4: {} @@ -5296,7 +5101,8 @@ snapshots: call-bound: 1.0.4 get-intrinsic: 1.3.0 - is-arrayish@0.2.1: {} + is-arrayish@0.2.1: + optional: true is-async-function@2.1.1: dependencies: @@ -5342,9 +5148,11 @@ snapshots: dependencies: call-bound: 1.0.4 - is-fullwidth-code-point@3.0.0: {} + is-fullwidth-code-point@3.0.0: + optional: true - is-generator-fn@2.1.0: {} + is-generator-fn@2.1.0: + optional: true is-generator-function@1.1.2: dependencies: @@ -5420,23 +5228,26 @@ snapshots: isobject@3.0.1: {} - istanbul-lib-coverage@3.2.2: {} + istanbul-lib-coverage@3.2.2: + optional: true istanbul-lib-instrument@6.0.3: dependencies: '@babel/core': 7.29.7 - '@babel/parser': 7.29.9 + '@babel/parser': 7.29.12 '@istanbuljs/schema': 0.1.6 istanbul-lib-coverage: 3.2.2 semver: 7.8.5 transitivePeerDependencies: - supports-color + optional: true istanbul-lib-report@3.0.1: dependencies: istanbul-lib-coverage: 3.2.2 make-dir: 4.0.0 supports-color: 7.2.0 + optional: true istanbul-lib-source-maps@5.0.6: dependencies: @@ -5445,23 +5256,27 @@ snapshots: istanbul-lib-coverage: 3.2.2 transitivePeerDependencies: - supports-color + optional: true istanbul-reports@3.2.0: dependencies: html-escaper: 2.0.2 istanbul-lib-report: 3.0.1 + optional: true jackspeak@3.4.3: dependencies: '@isaacs/cliui': 8.0.2 optionalDependencies: '@pkgjs/parseargs': 0.11.0 + optional: true jest-changed-files@30.5.1: dependencies: execa: 5.1.1 jest-util: 30.5.1 p-limit: 3.1.0 + optional: true jest-circus@30.5.2: dependencies: @@ -5488,6 +5303,7 @@ snapshots: transitivePeerDependencies: - babel-plugin-macros - supports-color + optional: true jest-cli@30.5.2(@types/node@22.16.5): dependencies: @@ -5507,6 +5323,7 @@ snapshots: - esbuild-register - supports-color - ts-node + optional: true jest-config@30.5.2(@types/node@22.16.5): dependencies: @@ -5538,13 +5355,7 @@ snapshots: transitivePeerDependencies: - babel-plugin-macros - supports-color - - jest-diff@30.5.0: - dependencies: - '@jest/diff-sequences': 30.5.0 - '@jest/get-type': 30.5.0 - chalk: 4.1.2 - pretty-format: 30.5.0 + optional: true jest-diff@30.5.2: dependencies: @@ -5556,6 +5367,7 @@ snapshots: jest-docblock@30.5.0: dependencies: detect-newline: 3.1.0 + optional: true jest-each@30.5.2: dependencies: @@ -5565,6 +5377,7 @@ snapshots: jest-regex-util: 30.5.0 jest-util: 30.5.1 pretty-format: 30.5.1 + optional: true jest-environment-node@30.5.2: dependencies: @@ -5575,20 +5388,7 @@ snapshots: jest-mock: 30.5.2 jest-util: 30.5.1 jest-validate: 30.5.1 - - jest-haste-map@30.5.0: - dependencies: - '@jest/types': 30.5.0 - '@parcel/watcher': 2.6.0 - '@types/node': 22.16.5 - anymatch: 3.1.3 - fb-watchman: 2.0.4 - fdir: 6.5.0(picomatch@4.0.7) - graceful-fs: 4.2.11 - jest-regex-util: 30.5.0 - jest-util: 30.5.0 - jest-worker: 30.5.0 - picomatch: 4.0.7 + optional: true jest-haste-map@30.5.1: dependencies: @@ -5603,18 +5403,13 @@ snapshots: jest-util: 30.5.1 jest-worker: 30.5.1 picomatch: 4.0.7 + optional: true jest-leak-detector@30.5.1: dependencies: '@jest/get-type': 30.5.0 pretty-format: 30.5.1 - - jest-matcher-utils@30.5.0: - dependencies: - '@jest/get-type': 30.5.0 - chalk: 4.1.2 - jest-diff: 30.5.0 - pretty-format: 30.5.0 + optional: true jest-matcher-utils@30.5.2: dependencies: @@ -5623,19 +5418,6 @@ snapshots: jest-diff: 30.5.2 pretty-format: 30.5.1 - jest-message-util@30.5.0: - dependencies: - '@babel/code-frame': 7.29.7 - '@jest/types': 30.5.0 - '@types/stack-utils': 2.0.3 - chalk: 4.1.2 - graceful-fs: 4.2.11 - jest-util: 30.5.0 - picomatch: 4.0.7 - pretty-format: 30.5.0 - slash: 3.0.0 - stack-utils: 2.0.6 - jest-message-util@30.5.1: dependencies: '@babel/code-frame': 7.29.7 @@ -5649,13 +5431,6 @@ snapshots: slash: 3.0.0 stack-utils: 2.0.6 - jest-mock@30.5.0: - dependencies: - '@jest/expect-utils': 30.5.0 - '@jest/types': 30.5.0 - '@types/node': 22.16.5 - jest-util: 30.5.0 - jest-mock@30.5.2: dependencies: '@jest/expect-utils': 30.5.2 @@ -5671,6 +5446,7 @@ snapshots: jest-snapshot: 30.5.2 transitivePeerDependencies: - supports-color + optional: true jest-resolve@30.5.1: dependencies: @@ -5681,6 +5457,7 @@ snapshots: jest-validate: 30.5.1 slash: 3.0.0 unrs-resolver: 1.13.0 + optional: true jest-runner@30.5.2: dependencies: @@ -5708,6 +5485,7 @@ snapshots: p-limit: 3.1.0 transitivePeerDependencies: - supports-color + optional: true jest-runtime@30.5.2: dependencies: @@ -5736,32 +5514,7 @@ snapshots: strip-bom: 4.0.0 transitivePeerDependencies: - supports-color - - jest-snapshot@30.5.0: - dependencies: - '@babel/core': 7.29.7 - '@babel/generator': 7.29.8 - '@babel/plugin-syntax-jsx': 7.29.7(@babel/core@7.29.7) - '@babel/plugin-syntax-typescript': 7.29.7(@babel/core@7.29.7) - '@babel/types': 7.29.8 - '@jest/expect-utils': 30.5.0 - '@jest/get-type': 30.5.0 - '@jest/snapshot-utils': 30.5.0 - '@jest/transform': 30.5.0 - '@jest/types': 30.5.0 - babel-preset-current-node-syntax: 1.2.0(@babel/core@7.29.7) - chalk: 4.1.2 - expect: 30.5.0 - graceful-fs: 4.2.11 - jest-diff: 30.5.0 - jest-matcher-utils: 30.5.0 - jest-message-util: 30.5.0 - jest-util: 30.5.0 - pretty-format: 30.5.0 - semver: 7.8.5 - synckit: 0.11.13 - transitivePeerDependencies: - - supports-color + optional: true jest-snapshot@30.5.2: dependencies: @@ -5788,15 +5541,7 @@ snapshots: synckit: 0.11.13 transitivePeerDependencies: - supports-color - - jest-util@30.5.0: - dependencies: - '@jest/types': 30.5.0 - '@types/node': 22.16.5 - chalk: 4.1.2 - ci-info: 4.4.0 - graceful-fs: 4.2.11 - picomatch: 4.0.7 + optional: true jest-util@30.5.1: dependencies: @@ -5815,6 +5560,7 @@ snapshots: chalk: 4.1.2 leven: 3.1.0 pretty-format: 30.5.1 + optional: true jest-watcher@30.5.2: dependencies: @@ -5826,14 +5572,7 @@ snapshots: emittery: 0.13.1 jest-util: 30.5.1 string-length: 4.0.2 - - jest-worker@30.5.0: - dependencies: - '@types/node': 22.16.5 - '@ungap/structured-clone': 1.4.0 - jest-util: 30.5.0 - merge-stream: 2.0.0 - supports-color: 8.1.1 + optional: true jest-worker@30.5.1: dependencies: @@ -5842,6 +5581,7 @@ snapshots: jest-util: 30.5.1 merge-stream: 2.0.0 supports-color: 8.1.1 + optional: true jest@30.5.2(@types/node@22.16.5): dependencies: @@ -5855,6 +5595,7 @@ snapshots: - esbuild-register - supports-color - ts-node + optional: true js-tokens@4.0.0: {} @@ -5862,6 +5603,7 @@ snapshots: dependencies: argparse: 1.0.10 esprima: 4.0.1 + optional: true js-yaml@4.1.0: dependencies: @@ -5871,7 +5613,8 @@ snapshots: json-buffer@3.0.1: {} - json-parse-even-better-errors@2.3.1: {} + json-parse-even-better-errors@2.3.1: + optional: true json-schema-traverse@0.4.1: {} @@ -5885,14 +5628,16 @@ snapshots: kind-of@6.0.3: {} - leven@3.1.0: {} + leven@3.1.0: + optional: true levn@0.4.1: dependencies: prelude-ls: 1.2.1 type-check: 0.4.0 - lines-and-columns@1.2.4: {} + lines-and-columns@1.2.4: + optional: true locate-path@3.0.0: dependencies: @@ -5902,6 +5647,7 @@ snapshots: locate-path@5.0.0: dependencies: p-locate: 4.1.0 + optional: true locate-path@6.0.0: dependencies: @@ -5911,7 +5657,8 @@ snapshots: lodash.merge@4.6.2: {} - lru-cache@10.4.3: {} + lru-cache@10.4.3: + optional: true lru-cache@11.5.3: {} @@ -5927,6 +5674,7 @@ snapshots: make-dir@4.0.0: dependencies: semver: 7.8.5 + optional: true math-intrinsics@1.1.0: {} @@ -5957,22 +5705,26 @@ snapshots: ms@2.1.3: {} - napi-postinstall@0.3.7: {} + napi-postinstall@0.3.7: + optional: true natural-compare@1.4.0: {} - node-addon-api@7.1.1: {} + node-addon-api@7.1.1: + optional: true node-environment-flags@1.0.6: dependencies: object.getownpropertydescriptors: 2.1.9 semver: 5.7.2 - node-int64@0.4.0: {} + node-int64@0.4.0: + optional: true node-releases@2.0.51: {} - normalize-path@3.0.0: {} + normalize-path@3.0.0: + optional: true npm-run-path@4.0.1: dependencies: @@ -6036,6 +5788,7 @@ snapshots: p-locate@4.1.0: dependencies: p-limit: 2.3.0 + optional: true p-locate@5.0.0: dependencies: @@ -6055,6 +5808,7 @@ snapshots: error-ex: 1.3.4 json-parse-even-better-errors: 2.3.1 lines-and-columns: 1.2.4 + optional: true parse-passwd@1.0.0: {} @@ -6070,6 +5824,7 @@ snapshots: dependencies: lru-cache: 10.4.3 minipass: 7.1.3 + optional: true path-scurry@2.0.2: dependencies: @@ -6095,6 +5850,7 @@ snapshots: pkg-dir@4.2.0: dependencies: find-up: 4.1.0 + optional: true possible-typed-array-names@1.1.0: {} @@ -6102,13 +5858,6 @@ snapshots: prettier@3.9.10: {} - pretty-format@30.5.0: - dependencies: - '@jest/react-is-18': react-is@18.3.1 - '@jest/react-is-19': react-is@19.3.1 - '@jest/schemas': 30.5.0 - ansi-styles: 5.2.0 - pretty-format@30.5.1: dependencies: '@jest/react-is-18': react-is@18.3.1 @@ -6118,7 +5867,8 @@ snapshots: punycode@2.3.1: {} - pure-rand@7.0.1: {} + pure-rand@7.0.1: + optional: true queue-microtask@1.2.3: {} @@ -6169,15 +5919,18 @@ snapshots: dependencies: jsesc: 3.1.0 - require-directory@2.1.1: {} + require-directory@2.1.1: + optional: true resolve-cwd@3.0.0: dependencies: resolve-from: 5.0.0 + optional: true resolve-from@4.0.0: {} - resolve-from@5.0.0: {} + resolve-from@5.0.0: + optional: true resolve@1.22.12: dependencies: @@ -6289,7 +6042,8 @@ snapshots: signal-exit@3.0.7: {} - signal-exit@4.1.0: {} + signal-exit@4.1.0: + optional: true slash@3.0.0: {} @@ -6300,7 +6054,8 @@ snapshots: source-map@0.6.1: {} - sprintf-js@1.0.3: {} + sprintf-js@1.0.3: + optional: true stack-utils@2.0.6: dependencies: @@ -6315,18 +6070,21 @@ snapshots: dependencies: char-regex: 1.0.2 strip-ansi: 6.0.1 + optional: true string-width@4.2.3: dependencies: emoji-regex: 8.0.0 is-fullwidth-code-point: 3.0.0 strip-ansi: 6.0.1 + optional: true string-width@5.1.2: dependencies: eastasianwidth: 0.2.0 emoji-regex: 9.2.2 strip-ansi: 7.2.0 + optional: true string.prototype.trim@1.2.11: dependencies: @@ -6355,12 +6113,15 @@ snapshots: strip-ansi@6.0.1: dependencies: ansi-regex: 5.0.1 + optional: true strip-ansi@7.2.0: dependencies: ansi-regex: 6.5.0 + optional: true - strip-bom@4.0.0: {} + strip-bom@4.0.0: + optional: true strip-final-newline@2.0.0: {} @@ -6373,18 +6134,21 @@ snapshots: supports-color@8.1.1: dependencies: has-flag: 4.0.0 + optional: true supports-preserve-symlinks-flag@1.0.0: {} synckit@0.11.13: dependencies: '@pkgr/core': 0.3.6 + optional: true test-exclude@7.0.2: dependencies: '@istanbuljs/schema': 0.1.6 glob: 10.5.0 minimatch: 10.2.6 + optional: true to-regex-range@5.0.1: dependencies: @@ -6402,9 +6166,11 @@ snapshots: dependencies: prelude-ls: 1.2.1 - type-detect@4.0.8: {} + type-detect@4.0.8: + optional: true - type-fest@0.21.3: {} + type-fest@0.21.3: + optional: true typed-array-buffer@1.0.3: dependencies: @@ -6497,6 +6263,7 @@ snapshots: '@unrs/resolver-binding-win32-arm64-msvc': 1.13.0 '@unrs/resolver-binding-win32-ia32-msvc': 1.13.0 '@unrs/resolver-binding-win32-x64-msvc': 1.13.0 + optional: true update-browserslist-db@1.2.3(browserslist@4.28.7): dependencies: @@ -6513,6 +6280,7 @@ snapshots: '@jridgewell/trace-mapping': 0.3.31 '@types/istanbul-lib-coverage': 2.0.6 convert-source-map: 2.0.0 + optional: true v8flags@3.2.0: dependencies: @@ -6570,23 +6338,28 @@ snapshots: ansi-styles: 4.3.0 string-width: 4.2.3 strip-ansi: 6.0.1 + optional: true wrap-ansi@8.1.0: dependencies: ansi-styles: 6.2.3 string-width: 5.1.2 strip-ansi: 7.2.0 + optional: true write-file-atomic@5.0.1: dependencies: imurmurhash: 0.1.4 signal-exit: 4.1.0 + optional: true - y18n@5.0.8: {} + y18n@5.0.8: + optional: true yallist@3.1.1: {} - yargs-parser@21.1.1: {} + yargs-parser@21.1.1: + optional: true yargs@17.7.3: dependencies: @@ -6597,5 +6370,6 @@ snapshots: string-width: 4.2.3 y18n: 5.0.8 yargs-parser: 21.1.1 + optional: true yocto-queue@0.1.0: {} diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml deleted file mode 100644 index 2e35c96..0000000 --- a/pnpm-workspace.yaml +++ /dev/null @@ -1,2 +0,0 @@ -onlyBuiltDependencies: - - core-js diff --git a/src/jest-globals.mts b/src/jest-globals.mts new file mode 100644 index 0000000..756131c --- /dev/null +++ b/src/jest-globals.mts @@ -0,0 +1,238 @@ +// Provides the Jest API used by the track's test files, on top of node:test, +// Jest's own `expect` package and `jest-mock`. setup.mts makes +// `import ... from '@jest/globals'` load this file, and loads it before the +// test file. This file also: +// +// 1. makes the API available as globals, as Jest did. +// 2. replaces `console` with Jest's BufferedConsole, which records each +// message with the stack it came from. The reporter uses that stack to work +// out which test printed the message. +// 3. runs the test file's jest.mock calls before the test file loads, as Jest +// did (see hoistMocks below). +import { BufferedConsole } from '@jest/console' +import { parse } from 'acorn' +import type { Statement } from 'acorn' +import { expect } from 'expect' +import { ModuleMocker } from 'jest-mock' +import fs from 'node:fs' +import { createRequire } from 'node:module' +import { + after, + afterEach as nodeAfterEach, + before, + beforeEach as nodeBeforeEach, + describe as nodeDescribe, + mock, + test as nodeTest, +} from 'node:test' +import { fileURLToPath, pathToFileURL } from 'node:url' +import { getCallSites } from 'node:util' +import { runInThisContext } from 'node:vm' + +/** Collects every console message, for the reporter. */ +export const testConsole = new BufferedConsole() +globalThis.console = testConsole + +// Jest fails a test or hook that takes longer than 5 seconds. +const TIMEOUT = 5000 + +type Callback = (error?: unknown) => void +type Result = Promise | void +type TestFn = (done: Callback) => Result + +// Jest passes a `done` callback to a function that takes an argument, and +// waits for it to be called. Node does the same for a function that takes two +// arguments (the test context, then `done`). +// +// Jest also failed a test that left a rejected promise unhandled. Node only +// does that if it notices the rejection before the test ends, so a test +// without `done` waits for Node to check for unhandled rejections first. +// +// Node's timer for the timeout can fire during that wait, after a slow test +// has already finished. Jest passed such a test, so a test that has used up +// its time skips the wait. +function wrap( + fn: TestFn, + timeout = TIMEOUT +): (context: unknown, done: Callback) => Result { + return fn.length > 0 + ? (_context, done): Result => fn(done) + : async (): Promise => { + const start = performance.now() + await (fn as () => Result)() + if (performance.now() - start < timeout) { + await new Promise((resolve) => { + setImmediate(resolve) + }) + } + } +} + +// Jest reported the test file as failed to run when the solution threw an +// error, or left a rejected promise unhandled, while the files were loading +// (for example at its top level). Node's test runner ignores these errors +// when the tests run in its own process. So we keep them here until the +// tests start, and the reporter reports the first one. +export const loadErrors: unknown[] = [] + +function keepLoadError(error: unknown): void { + loadErrors.push(error) +} + +process.on('uncaughtException', keepLoadError) +process.on('unhandledRejection', keepLoadError) + +// Node runs the first test straight after loading the test file, before it +// reports unhandled rejections. So the first describe or test adds a hook +// that waits for those reports before any test runs. +let waitingForLoadErrors = false + +function waitForLoadErrors(): void { + if (waitingForLoadErrors) { + return + } + waitingForLoadErrors = true + + before(async () => { + await new Promise((resolve) => { + setImmediate(resolve) + }) + process.off('uncaughtException', keepLoadError) + process.off('unhandledRejection', keepLoadError) + }) +} + +export function test(name: string, fn: TestFn, timeout = TIMEOUT): void { + waitForLoadErrors() + void nodeTest(name, { timeout }, wrap(fn, timeout)) +} +test.skip = (name: string, fn: TestFn): void => { + void nodeTest(name, { skip: true }, wrap(fn)) +} + +// bin/prepare.sh turns xtest, xit and xdescribe into test, it and describe in +// the test file, so that every test runs. +export const it = test +export const xtest = test.skip +export const xit = test.skip + +export function describe(name: string, fn: () => void): void { + waitForLoadErrors() + void nodeDescribe(name, () => { + fn() + }) +} +describe.skip = (name: string, fn: () => void): void => { + void nodeDescribe(name, { skip: true }, () => { + fn() + }) +} +export const xdescribe = describe.skip + +export function beforeEach(fn: TestFn, timeout = TIMEOUT): void { + nodeBeforeEach(wrap(fn, timeout), { timeout }) +} +export function afterEach(fn: TestFn, timeout = TIMEOUT): void { + nodeAfterEach(wrap(fn, timeout), { timeout }) +} +export function beforeAll(fn: TestFn, timeout = TIMEOUT): void { + before(wrap(fn, timeout), { timeout }) +} +export function afterAll(fn: TestFn, timeout = TIMEOUT): void { + after(wrap(fn, timeout), { timeout }) +} + +const mocker = new ModuleMocker(globalThis) +const mockedModules = new Set() + +export const jest = { + fn: mocker.fn.bind(mocker), + spyOn: mocker.spyOn.bind(mocker), + mocked: mocker.mocked.bind(mocker), + replaceProperty: mocker.replaceProperty.bind(mocker), + clearAllMocks: mocker.clearAllMocks.bind(mocker), + resetAllMocks: mocker.resetAllMocks.bind(mocker), + restoreAllMocks: mocker.restoreAllMocks.bind(mocker), + + // Replaces a module with the object returned by `factory`. This uses Node's + // mock.module, which needs the --experimental-test-module-mocks flag. + mock(moduleName: string, factory: () => Record): void { + const url = pathToFileURL(createRequire(callerFile()).resolve(moduleName)) + if (mockedModules.has(url.href)) { + // hoistMocks already ran this call, before the test file loaded. + return + } + mockedModules.add(url.href) + + const { default: defaultExport, ...namedExports } = factory() + mock.module(url.href, { defaultExport, namedExports }) + }, +} + +/** The file of the function that called the function calling this one. */ +function callerFile(): string { + // [0] is this function, [1] is its caller, and [2] is the caller's caller. + const file = getCallSites(3)[2]?.scriptName ?? '' + return file.startsWith('file:') ? fileURLToPath(file) : file +} + +export { expect } + +Object.assign(globalThis, { + afterAll, + afterEach, + beforeAll, + beforeEach, + describe, + expect, + it, + jest, + test, + xdescribe, + xit, + xtest, +}) + +// Jest moved each jest.mock call above the imports of the test file (with +// babel-plugin-jest-hoist), so the mock replaced the module before anything +// imported it. Native ES modules load all their imports before any of their +// code runs, which would be too late for the mock. So before Node loads the +// test file, this finds its top-level jest.mock calls with acorn and runs them +// here. As in Jest, a mock factory may only use globals such as `jest`. +function hoistMocks(testFile: string): void { + const source = fs.readFileSync(testFile, 'utf8') + + let body: Statement[] + try { + ;({ body } = parse(source, { + ecmaVersion: 'latest', + sourceType: 'module', + allowHashBang: true, + }) as { body: Statement[] }) + } catch { + // Node will report the syntax error when it loads the test file. + return + } + + const calls = body + .filter( + (statement) => + statement.type === 'ExpressionStatement' && + statement.expression.type === 'CallExpression' && + statement.expression.callee.type === 'MemberExpression' && + statement.expression.callee.object.type === 'Identifier' && + statement.expression.callee.object.name === 'jest' && + statement.expression.callee.property.type === 'Identifier' && + statement.expression.callee.property.name === 'mock' + ) + .map((statement) => source.slice(statement.start, statement.end)) + + if (calls.length > 0) { + // Naming the test file lets jest.mock resolve paths from it. + runInThisContext(calls.join('\n'), { filename: testFile }) + } +} + +if (process.env.TEST_FILE) { + hoistMocks(process.env.TEST_FILE) +} diff --git a/src/jest/setup.ts b/src/jest/setup.ts deleted file mode 100644 index fed1645..0000000 --- a/src/jest/setup.ts +++ /dev/null @@ -1,5 +0,0 @@ -// This used to be a setup script,b ut we replaced it with -// code in the test-runner. -// -// It's still here, so that if we need it, we don't need to -// reconfigure everything. diff --git a/src/output.ts b/src/output.ts index 8ecf069..86de565 100644 --- a/src/output.ts +++ b/src/output.ts @@ -1,16 +1,38 @@ /* eslint-disable @typescript-eslint/naming-convention */ import type { ConsoleBuffer } from '@jest/console' -import type { - AggregatedResult, - AssertionResult, - TestResult, -} from '@jest/test-result' -import type { Config } from '@jest/types' import fs from 'fs' import path from 'path' +import { locateSyntaxError } from './syntax-error' import { parseTests } from './tests' import type { ParsedTests, TestCase } from './tests' +// The parts of Jest's results that this file reads. The reporter builds them +// from the events of Node's test runner. +export interface AssertionResult { + ancestorTitles: string[] + title: string + status: 'passed' | 'failed' | 'pending' | 'skipped' + failureMessages: string[] +} + +export interface TestResult { + testFilePath: string + failureMessage?: string + testExecError?: { message: string } + console?: ConsoleBuffer + testResults: AssertionResult[] +} + +export interface AggregatedResult { + numFailedTests: number + numFailedTestSuites: number + numPassedTests: number + numPendingTests: number + numPendingTestSuites: number + numRuntimeErrorTestSuites: number + testResults: TestResult[] +} + interface OutputInterface { status: 'fail' | 'pass' | 'error' message: string @@ -40,16 +62,13 @@ const OUTPUT_VERSION = 3 export class Output { private readonly results: Partial & Pick - private readonly globalConfig: Config.GlobalConfig private readonly outputFile: string private readonly sources: Record private readonly config: null | ExerciseConfig - constructor(globalConfig: Config.GlobalConfig) { - this.globalConfig = globalConfig + constructor(outputFile: string) { this.results = { tests: [] } - this.outputFile = - this.globalConfig.outputFile ?? path.join(process.cwd(), 'results.json') + this.outputFile = outputFile this.config = findConfig(path.dirname(this.outputFile)) this.sources = {} @@ -61,26 +80,6 @@ export class Output { } public finish(aggregatedResults: AggregatedResult): void { - // If Jest found no test files, report that no tests ran. Checking here - // saves run.sh from starting Jest a second time to list the test files. - // Version 3 output can't have an empty list of tests, so this uses the - // version 1 format, which has no tests key. - if (!this.results.status && aggregatedResults.numTotalTestSuites === 0) { - const artifact = JSON.stringify( - { - version: 1, - status: 'error', - message: - 'The submitted code was not subjected to any type or execution ' + - 'tests. At least one test was expected.', - }, - undefined, - 2 - ) - fs.writeFileSync(this.outputFile, artifact) - return - } - if (!this.results.status) { this.results.status = aggregatedResults.numRuntimeErrorTestSuites === 0 && @@ -215,8 +214,11 @@ export class Output { this.error( sanitizeErrorMessage( specFilePath, - testResult.failureMessage ?? - 'Something went wrong when running the tests.' + locateSyntaxError( + specFilePath, + testResult.failureMessage ?? + 'Something went wrong when running the tests.' + ) ) ) return @@ -318,9 +320,10 @@ function buildOutput( return undefined } + // Frames end in "12)", or in "12" for a function with no name. const messageLoc = { line: Number(line), - column: Number(column.slice(0, column.length - 1)), + column: parseInt(column, 10), } return (foundTest = tests.find(({ testNode }) => { if (messageLoc.line < testNode.loc.start.line) { @@ -427,6 +430,10 @@ function sanitizeErrorMessage(specFilePath: string, message: string): string { path.dirname(process.cwd()), ] + // Stack frames in ES modules name files by URL (file:///...), and Jest's + // code frames shorten that to file:/... + dirs.unshift(...dirs.flatMap((dir) => [`file://${dir}`, `file:${dir}`])) + dirs.forEach((sensitivePath) => { while (message.includes(sensitivePath)) { message = message.replace(sensitivePath, '') diff --git a/src/reporter.mts b/src/reporter.mts new file mode 100644 index 0000000..77ff9c3 --- /dev/null +++ b/src/reporter.mts @@ -0,0 +1,165 @@ +// A reporter for Node's test runner (`node --test --test-reporter`). It +// collects the result of each test from the runner's events, then writes +// results.json through Output, as the Jest reporter did. +// +// bin/run.sh runs the tests with --test-isolation=none, so the tests, +// jest-globals.mjs and this reporter share one process. That lets the reporter +// read the console messages collected by jest-globals.mjs. +// +// Node gives reporters no options, so run.sh passes the test file and the +// results file in the TEST_FILE and RESULTS_FILE environment variables. +import path from 'node:path' +import type { TestEvent } from 'node:test/reporters' +import { fileURLToPath } from 'node:url' +import { inspect } from 'node:util' +import { Output } from './output.js' +import type { AggregatedResult, AssertionResult, TestResult } from './output.js' + +const RUNNER_ROOT = path.dirname(path.dirname(fileURLToPath(import.meta.url))) + +type TestFailure = Error & { code?: string; failureType?: string } + +export default async function* reporter( + source: AsyncIterable +): AsyncGenerator { + const testFile = process.env.TEST_FILE ?? '' + const output = new Output(process.env.RESULTS_FILE ?? 'results.json') + + const ancestors: string[] = [] + const results: AssertionResult[] = [] + let pendingSuites = 0 + + // Set when the test file can't run: it fails to load, or a describe block + // throws. Jest reported both as a test suite that failed to run. + let failureMessage: string | undefined + + for await (const event of source) { + if (event.type === 'test:start') { + ancestors[event.data.nesting] = event.data.name + } + + if (event.type !== 'test:pass' && event.type !== 'test:fail') { + continue + } + + const { data } = event + const error = + event.type === 'test:fail' + ? (event.data.details.error as TestFailure) + : undefined + + // Node reports a file that fails to load as a failed test, with the + // error itself. Every other failure wraps the error in ERR_TEST_FAILURE. + if (error && error.code !== 'ERR_TEST_FAILURE') { + failureMessage ??= formatError(error, testFile) + continue + } + + // Node reports a test file that defines no tests as one passing test, + // named after the file. Jest reported that the file failed to run. + if (data.nesting === 0 && data.name === data.file) { + failureMessage ??= 'Your test suite must contain at least one test.' + continue + } + + if (data.details.type === 'suite') { + if (data.skip) { + pendingSuites += 1 + } + if (error?.failureType === 'testCodeFailure') { + failureMessage ??= formatError(error, testFile) + } + continue + } + + results.push({ + ancestorTitles: ancestors.slice(0, data.nesting), + title: data.name, + status: data.skip || data.todo ? 'pending' : error ? 'failed' : 'passed', + failureMessages: error ? [formatError(error, testFile)] : [], + }) + } + + // Node loads this reporter before the preloaded setup.mts, so this file + // imports jest-globals.mjs only now, to let setup.mts load it first. + const { loadErrors, testConsole } = await import('./jest-globals.mjs') + + if (loadErrors.length > 0) { + failureMessage ??= formatError(loadErrors[0] as TestFailure, testFile) + } + + const testResult: TestResult = { + testFilePath: testFile, + failureMessage, + console: testConsole.getBuffer(), + testResults: results, + } + + const count = (status: AssertionResult['status']): number => + results.filter((result) => result.status === status).length + + const aggregatedResults: AggregatedResult = { + numFailedTests: count('failed'), + numFailedTestSuites: count('failed') > 0 ? 1 : 0, + numPassedTests: count('passed'), + numPendingTests: count('pending'), + numPendingTestSuites: pendingSuites, + numRuntimeErrorTestSuites: failureMessage ? 1 : 0, + testResults: [testResult], + } + + output.testFinished(testFile, testResult, aggregatedResults) + output.finish(aggregatedResults) + + yield `${aggregatedResults.numPassedTests} passed, ${aggregatedResults.numFailedTests} failed\n` +} + +/** + * Turns an error into a message in the shape Jest gave: the error's own stack, + * without the frames of the test function and the runner. So the message + * keeps the frames in the student's code. + */ +function formatError(error: TestFailure, testFile: string): string { + // Node wraps the error from a failed test or hook in ERR_TEST_FAILURE. + const cause: unknown = error.code === 'ERR_TEST_FAILURE' ? error.cause : error + + if (cause instanceof Error && typeof cause.stack === 'string') { + return cutStack(cause.stack, testFile) + } + + if ( + error.code === 'ERR_TEST_FAILURE' && + error.failureType !== 'testCodeFailure' + ) { + // A timeout, or a test cancelled because its parent failed. The cause is + // Node's message, such as "test timed out after 5000ms". + return String(cause) + } + + return `thrown: ${inspect(cause)}` +} + +function cutStack(stack: string, testFile: string): string { + const lines = stack.split('\n') + const isFrame = (line: string): boolean => /^\s+at /.test(line) + + // Keep the frames up to the first one in Node or in the runner. Then drop + // the frames at the end that are in the test file, which are the test + // function itself. Jest cut the stack at the same place. + let end = lines.findIndex( + (line) => + isFrame(line) && (line.includes('node:') || line.includes(RUNNER_ROOT)) + ) + if (end === -1) { + end = lines.length + } + while ( + end > 0 && + isFrame(lines[end - 1]) && + lines[end - 1].includes(testFile) + ) { + end -= 1 + } + + return lines.slice(0, end).join('\n') +} diff --git a/src/reporter.ts b/src/reporter.ts deleted file mode 100644 index 71f5f3c..0000000 --- a/src/reporter.ts +++ /dev/null @@ -1,73 +0,0 @@ -import type { - TestContext, - Reporter, - ReporterOnStartOptions, - Test, -} from '@jest/reporters' -import type { AggregatedResult, TestResult } from '@jest/test-result' -import type { Config } from '@jest/types' -import { Output } from './output' - -export default class StandardReporter implements Reporter { - private readonly output: Output - - private error: null | Error - - constructor(globalConfig: Config.GlobalConfig) { - this.error = null - this.output = new Output(globalConfig) - } - - public getLastError(): Error | undefined { - if (this.error) { - return this.error - } - } - - public setError(error: Error): void { - this.error = error - this.output.error(error.message) - } - - /** - * @param results - * @param options - */ - public onRunStart( - _results: AggregatedResult, - _options: ReporterOnStartOptions - ): void { - // no-op - } - - /** - * @param test - */ - public onTestStart(test: Test): void { - this.output.testStarted(test.path) - } - - /** - * @param test - * @param testResult - * @param results - */ - public async onTestFileResult( - test: Test, - testResult: TestResult, - results: AggregatedResult - ): Promise { - this.output.testFinished(test.path, testResult, results) - } - - /** - * @param contexts - * @param aggregatedResults - */ - public onRunComplete( - _contexts: Set, - aggregatedResults: AggregatedResult - ): Promise | void { - this.output.finish(aggregatedResults) - } -} diff --git a/src/setup.mts b/src/setup.mts new file mode 100644 index 0000000..55893d2 --- /dev/null +++ b/src/setup.mts @@ -0,0 +1,48 @@ +// Runs the track's Jest-style test files on Node's built-in test runner. +// +// bin/run.sh preloads this file with `node --import`, so it runs before the +// test file loads. Node loads the solution and the test file as they are, as +// native ES modules. Jest used to load every file through Babel first. +// +// This file registers a module hook that does two things: +// +// 1. It makes `import ... from '@jest/globals'` load jest-globals.mjs, which +// provides the Jest API on top of node:test. +// 2. It lets relative imports leave out the `.js` extension, as Jest did +// (`import { twoFer } from './two-fer'`). +// +// Worker threads started by a solution also run this file, because they +// inherit Node's options. They only need the hook, so they don't load the +// Jest API, which would make every worker start much more slowly. +import { registerHooks } from 'node:module' +import { isMainThread } from 'node:worker_threads' + +const jestGlobals = new URL('./jest-globals.mjs', import.meta.url).href + +registerHooks({ + resolve(specifier, context, nextResolve) { + if (specifier === '@jest/globals') { + return { url: jestGlobals, shortCircuit: true } + } + + try { + return nextResolve(specifier, context) + } catch (error) { + if ( + (error as NodeJS.ErrnoException).code === 'ERR_MODULE_NOT_FOUND' && + specifier.startsWith('.') + ) { + return nextResolve(`${specifier}.js`, context) + } + throw error + } + }, +}) + +if (isMainThread) { + // Jest ran with --colors, which makes chalk colour the messages from + // `expect`. Node has no such option, so this adds the flag to the process's + // arguments, where chalk looks for it, before Jest's packages load. + process.argv.push('--colors') + await import(jestGlobals) +} diff --git a/src/syntax-error.ts b/src/syntax-error.ts new file mode 100644 index 0000000..99c6a49 --- /dev/null +++ b/src/syntax-error.ts @@ -0,0 +1,75 @@ +// Node loads the files as native ES modules, so a syntax error comes straight +// from Node, as just "SyntaxError: Unexpected token 'const'", with no file +// name or line. Babel used to name the file and show the line. When the +// message has no file name, we parse the exercise's files with acorn to find +// the error, and report it in the same shape as Babel did: +// +// SyntaxError: /two-fer.js: Unexpected keyword 'const' (1:13) +// +// > 1 | export const const () => { ( +// | ^ +// 2 | + +import fs from 'fs' +import path from 'path' +import { parse } from 'acorn' + +type AcornSyntaxError = SyntaxError & { loc?: { line: number; column: number } } + +export function locateSyntaxError( + specFilePath: string, + message: string +): string { + if ( + !message.includes('SyntaxError: ') || + message.includes('SyntaxError: /') + ) { + return message + } + + const dir = path.dirname(specFilePath) + const files = fs + .readdirSync(dir) + .filter((file) => /\.m?js$/.test(file) && !file.includes('.config.')) + .map((file) => path.join(dir, file)) + .sort((a, b) => Number(a === specFilePath) - Number(b === specFilePath)) + + for (const file of files) { + const source = fs.readFileSync(file, 'utf8') + try { + parse(source, { + ecmaVersion: 'latest', + sourceType: 'module', + allowHashBang: true, + }) + } catch (error) { + const { loc, message: reason } = error as AcornSyntaxError + if (!loc) { + continue + } + return `SyntaxError: ${file}: ${reason}\n\n${codeFrame(source, loc.line, loc.column)}\n` + } + } + + return message +} + +// Shows the lines around the error in the same layout as Babel's code frame. +function codeFrame(source: string, line: number, column: number): string { + const lines = source.split(/\r?\n/) + const first = Math.max(1, line - 2) + const last = Math.min(lines.length, line + 3) + const width = String(last).length + const frame: string[] = [] + + for (let n = first; n <= last; n++) { + const marker = n === line ? '>' : ' ' + const code = lines[n - 1] ? ` ${lines[n - 1]}` : '' + frame.push(` ${marker} ${String(n).padStart(width)} |${code}`) + if (n === line) { + frame.push(` ${' '.repeat(width)} | ${' '.repeat(column)}^`) + } + } + + return frame.join('\n') +} diff --git a/test/fixtures/two-fer/error/empty/expected_results.json b/test/fixtures/two-fer/error/empty/expected_results.json new file mode 100644 index 0000000..edab60d --- /dev/null +++ b/test/fixtures/two-fer/error/empty/expected_results.json @@ -0,0 +1,6 @@ +{ + "status": "error", + "message": "/two-fer.spec.js:1\nimport { twoFer } from './two-fer';\n ^^^^^^\nSyntaxError: Named export 'twoFer' not found. The requested module './two-fer' is a CommonJS module, which may not support all module.exports as named exports.\nCommonJS modules can always be imported via the default export, for example using:\n\nimport pkg from './two-fer';\nconst { twoFer } = pkg;\n", + "tests": [], + "version": 3 +} \ No newline at end of file diff --git a/test/fixtures/two-fer/fail/empty/two-fer.js b/test/fixtures/two-fer/error/empty/two-fer.js similarity index 100% rename from test/fixtures/two-fer/fail/empty/two-fer.js rename to test/fixtures/two-fer/error/empty/two-fer.js diff --git a/test/fixtures/two-fer/fail/empty/two-fer.spec.js b/test/fixtures/two-fer/error/empty/two-fer.spec.js similarity index 100% rename from test/fixtures/two-fer/fail/empty/two-fer.spec.js rename to test/fixtures/two-fer/error/empty/two-fer.spec.js diff --git a/test/fixtures/two-fer/error/syntax/expected_results.json b/test/fixtures/two-fer/error/syntax/expected_results.json index 4c3ba28..8206fd8 100644 --- a/test/fixtures/two-fer/error/syntax/expected_results.json +++ b/test/fixtures/two-fer/error/syntax/expected_results.json @@ -1,6 +1,6 @@ { "status": "error", - "message": "SyntaxError: /two-fer.js: Unexpected keyword 'const'. (1:13)\n\n > 1 | export const const () => { (\n | ^\n 2 |\n", + "message": "SyntaxError: /two-fer.js: Unexpected keyword 'const' (1:13)\n\n > 1 | export const const () => { (\n | ^\n 2 |\n", "tests": [], "version": 3 } \ No newline at end of file diff --git a/test/fixtures/two-fer/fail/empty/expected_results.json b/test/fixtures/two-fer/fail/empty/expected_results.json deleted file mode 100644 index 527649c..0000000 --- a/test/fixtures/two-fer/fail/empty/expected_results.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "status": "fail", - "tests": [ - { - "name": "twoFer() > no name given", - "status": "fail", - "message": "TypeError: (0 , _twoFer.twoFer) is not a function", - "output": null, - "test_code": "expect(twoFer()).toEqual('One for you, one for me.');" - }, - { - "name": "twoFer() > a name given", - "status": "fail", - "message": "TypeError: (0 , _twoFer.twoFer) is not a function", - "output": null, - "test_code": "const name = 'Alice';\nexpect(twoFer(name)).toEqual('One for Alice, one for me.');" - }, - { - "name": "twoFer() > another name given", - "status": "fail", - "message": "TypeError: (0 , _twoFer.twoFer) is not a function", - "output": null, - "test_code": "const name = 'Bob';\nexpect(twoFer(name)).toEqual('One for Bob, one for me.');" - } - ], - "version": 3 -} \ No newline at end of file diff --git a/test/smoke.test.mjs b/test/smoke.test.mjs index f06cb2b..e98ec04 100644 --- a/test/smoke.test.mjs +++ b/test/smoke.test.mjs @@ -35,7 +35,7 @@ shelljs.echo( assertPass('two-fer', join(fixtures, 'two-fer', 'npm')) /** Test failures */ -const failures = ['tests', 'empty'] +const failures = ['tests'] failures.forEach((cause) => { const input = join(fixtures, 'two-fer', 'fail', cause) @@ -51,7 +51,9 @@ failures.forEach((cause) => { }) /** Test errors */ -const errors = ['missing', 'syntax', 'malformed_tests'] +// An empty solution has no twoFer export. Node checks the imports of a native +// ES module before any test runs, so the whole test file fails to run. +const errors = ['empty', 'missing', 'syntax', 'malformed_tests'] errors.forEach((cause) => { const input = join(fixtures, 'two-fer', 'error', cause) From 23ee3c51c12d474ec7ca3252df05bc5dbc13b3fa Mon Sep 17 00:00:00 2001 From: iHiD <286476+iHiD@users.noreply.github.com> Date: Tue, 24 Nov 2026 19:47:19 +0900 Subject: [PATCH 3/4] Use only stable Node APIs to load the tests The runner used three Node features that aren't marked stable: --import to preload setup.mts, module.registerHooks to find @jest/globals and files imported without their extension, and mock.module (with --experimental-test-module-mocks) for jest.mock. It also called util.getCallSites. Node now preloads setup.cjs with --require. Before the test file loads, src/imports.ts parses the test file, and each file it imports, with acorn. It adds the missing extension to relative imports and points @jest/globals at the runner's jest-globals.mjs. jest.mock writes a small module in place of the mocked file, which exports what the factory returned, and puts the original back when the process exits. Co-authored-by: iHiD <286476+iHiD@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 --- bin/run.sh | 9 +- src/imports.ts | 179 ++++++++++++++++++ src/jest-globals.mts | 104 ++++++---- src/reporter.mts | 4 +- src/setup.cts | 31 +++ src/setup.mts | 48 ----- .../two-fer/error/empty/expected_results.json | 2 +- 7 files changed, 286 insertions(+), 91 deletions(-) create mode 100644 src/imports.ts create mode 100644 src/setup.cts delete mode 100644 src/setup.mts diff --git a/bin/run.sh b/bin/run.sh index 1937b59..5d3976a 100755 --- a/bin/run.sh +++ b/bin/run.sh @@ -78,7 +78,7 @@ set -euo pipefail ROOT="$(realpath $(dirname "$0")/..)" REPORTER="$ROOT/dist/reporter.mjs" -SETUP="$ROOT/dist/setup.mjs" +SETUP="$ROOT/dist/setup.cjs" echo " " echo "╔═════════════════════════════════════════════════════════════╗" @@ -260,18 +260,15 @@ if test -f "${OUTPUT}${test_file}"; then echo "⚙️ node --test ${test_file}" echo "" - # Run the tests with Node's built-in test runner. setup.mjs provides the + # Run the tests with Node's built-in test runner. setup.cjs provides the # Jest API the tests use, and reporter.mjs writes results.json. # # --test-isolation=none runs the test file in this process, instead of # starting another one, and lets the reporter read the console messages. # --test-force-exit stops the process once the tests have finished, even # if the solution leaves a timer running. - # --experimental-test-module-mocks enables jest.mock (see setup.mts). cd "${OUTPUT}" && TEST_FILE="${OUTPUT}${test_file}" RESULTS_FILE="${result_file}" node \ - --import "${SETUP}" \ - --experimental-test-module-mocks \ - --disable-warning=ExperimentalWarning \ + --require "${SETUP}" \ --test \ --test-isolation=none \ --test-force-exit \ diff --git a/src/imports.ts b/src/imports.ts new file mode 100644 index 0000000..7c2018f --- /dev/null +++ b/src/imports.ts @@ -0,0 +1,179 @@ +// Rewrites the import paths in the test file, and in the files it imports, so +// that Node's own module loader can find every file. setup.cts calls this +// before the test file loads. +// +// Jest found these files itself. Node only finds a relative import if it +// names the file in full, and only finds `@jest/globals` in a node_modules +// folder. A module hook could fix both while the files load, but Node's hooks +// are not yet stable. So this changes the paths in the files instead: +// +// - `'./two-fer'` becomes `'./two-fer.js'` if two-fer.js exists, and +// `'./lib'` becomes `'./lib/index.js'` if lib is a folder. The track's +// files name the file in full, but solutions to earlier versions of the +// exercises, and many students' own files, leave out the extension. +// - `'@jest/globals'` becomes the path of the runner's jest-globals.mjs. So +// solutions still can't import any of the runner's packages. +// +// The files are parsed with acorn, so text in strings and comments is never +// changed. A file that fails to parse is left alone, and Node will report the +// syntax error when it loads the file. +import { parse } from 'acorn' +import type { Node } from 'acorn' +import fs from 'node:fs' +import path from 'node:path' +import { pathToFileURL } from 'node:url' + +const JEST_GLOBALS = path.join(__dirname, 'jest-globals.mjs') + +interface Edit { + start: number + end: number + text: string +} + +type StringLiteral = Node & { type: 'Literal'; value: string; raw: string } + +export function rewriteImports(entryFile: string): void { + const visited = new Set() + + function visit(file: string): void { + if (visited.has(file)) { + return + } + visited.add(file) + + const source = fs.readFileSync(file, 'utf8') + let program: Node + try { + program = parse(source, { + ecmaVersion: 'latest', + sourceType: 'module', + allowHashBang: true, + }) + } catch { + return + } + + const edits: Edit[] = [] + for (const { literal, isRequire } of importPaths(program)) { + const specifier = literal.value + let replacement: string | undefined + + if (specifier === '@jest/globals') { + replacement = isRequire + ? JEST_GLOBALS + : pathToFileURL(JEST_GLOBALS).href + } else if (specifier.startsWith('./') || specifier.startsWith('../')) { + const target = path.resolve(path.dirname(file), specifier) + const found = findFile(target) + if (found) { + visit(found) + // require() finds a file without its extension by itself. + if (!isRequire && found !== target) { + replacement = specifier + found.slice(target.length) + } + } + } + + if (replacement !== undefined) { + const quote = literal.raw[0] + edits.push({ + start: literal.start, + end: literal.end, + text: `${quote}${replacement}${quote}`, + }) + } + } + + if (edits.length === 0) { + return + } + + let rewritten = source + for (const edit of edits.sort((a, b) => b.start - a.start)) { + rewritten = + rewritten.slice(0, edit.start) + edit.text + rewritten.slice(edit.end) + } + fs.writeFileSync(file, rewritten) + } + + visit(path.resolve(entryFile)) +} + +/** Finds the file Jest would load for a relative import, as Jest did. */ +function findFile(target: string): string | undefined { + for (const candidate of [ + target, + `${target}.js`, + path.join(target, 'index.js'), + ]) { + if (fs.statSync(candidate, { throwIfNoEntry: false })?.isFile()) { + return candidate + } + } + return undefined +} + +/** + * The string paths in import and export declarations, in `import()`, and in + * `require()` calls. + */ +function importPaths( + program: Node +): { literal: StringLiteral; isRequire: boolean }[] { + const found: { literal: StringLiteral; isRequire: boolean }[] = [] + + function walk(node: Node): void { + const value = node as Node & Record + + if ( + node.type === 'ImportDeclaration' || + node.type === 'ExportNamedDeclaration' || + node.type === 'ExportAllDeclaration' || + node.type === 'ImportExpression' + ) { + if (isStringLiteral(value.source)) { + found.push({ literal: value.source, isRequire: false }) + } + } else if (node.type === 'CallExpression') { + const callee = value.callee as Node & { name?: string } + const [first] = value.arguments as Node[] + if ( + callee.type === 'Identifier' && + callee.name === 'require' && + isStringLiteral(first) + ) { + found.push({ literal: first, isRequire: true }) + } + } + + for (const child of Object.values(value)) { + if (Array.isArray(child)) { + child.forEach((item) => { + if (isNode(item)) walk(item) + }) + } else if (isNode(child)) { + walk(child) + } + } + } + + walk(program) + return found +} + +function isNode(value: unknown): value is Node { + return ( + typeof value === 'object' && + value !== null && + typeof (value as { type?: unknown }).type === 'string' + ) +} + +function isStringLiteral(value: unknown): value is StringLiteral { + return ( + isNode(value) && + value.type === 'Literal' && + typeof (value as { value?: unknown }).value === 'string' + ) +} diff --git a/src/jest-globals.mts b/src/jest-globals.mts index 756131c..315ced1 100644 --- a/src/jest-globals.mts +++ b/src/jest-globals.mts @@ -1,7 +1,7 @@ // Provides the Jest API used by the track's test files, on top of node:test, -// Jest's own `expect` package and `jest-mock`. setup.mts makes -// `import ... from '@jest/globals'` load this file, and loads it before the -// test file. This file also: +// Jest's own `expect` package and `jest-mock`. setup.cts loads it before the +// test file, and points the test file's `import ... from '@jest/globals'` at +// it (see imports.ts). This file also: // // 1. makes the API available as globals, as Jest did. // 2. replaces `console` with Jest's BufferedConsole, which records each @@ -11,7 +11,7 @@ // did (see hoistMocks below). import { BufferedConsole } from '@jest/console' import { parse } from 'acorn' -import type { Statement } from 'acorn' +import type { CallExpression, ExpressionStatement, Statement } from 'acorn' import { expect } from 'expect' import { ModuleMocker } from 'jest-mock' import fs from 'node:fs' @@ -22,11 +22,8 @@ import { before, beforeEach as nodeBeforeEach, describe as nodeDescribe, - mock, test as nodeTest, } from 'node:test' -import { fileURLToPath, pathToFileURL } from 'node:url' -import { getCallSites } from 'node:util' import { runInThisContext } from 'node:vm' /** Collects every console message, for the reporter. */ @@ -143,7 +140,6 @@ export function afterAll(fn: TestFn, timeout = TIMEOUT): void { } const mocker = new ModuleMocker(globalThis) -const mockedModules = new Set() export const jest = { fn: mocker.fn.bind(mocker), @@ -154,26 +150,10 @@ export const jest = { resetAllMocks: mocker.resetAllMocks.bind(mocker), restoreAllMocks: mocker.restoreAllMocks.bind(mocker), - // Replaces a module with the object returned by `factory`. This uses Node's - // mock.module, which needs the --experimental-test-module-mocks flag. - mock(moduleName: string, factory: () => Record): void { - const url = pathToFileURL(createRequire(callerFile()).resolve(moduleName)) - if (mockedModules.has(url.href)) { - // hoistMocks already ran this call, before the test file loaded. - return - } - mockedModules.add(url.href) - - const { default: defaultExport, ...namedExports } = factory() - mock.module(url.href, { defaultExport, namedExports }) - }, -} - -/** The file of the function that called the function calling this one. */ -function callerFile(): string { - // [0] is this function, [1] is its caller, and [2] is the caller's caller. - const file = getCallSites(3)[2]?.scriptName ?? '' - return file.startsWith('file:') ? fileURLToPath(file) : file + // hoistMocks below has already run every top-level jest.mock call in the + // test file, before the test file loaded. So when the test file itself + // runs the call, there is nothing left to do. + mock(): void {}, } export { expect } @@ -196,9 +176,55 @@ Object.assign(globalThis, { // Jest moved each jest.mock call above the imports of the test file (with // babel-plugin-jest-hoist), so the mock replaced the module before anything // imported it. Native ES modules load all their imports before any of their -// code runs, which would be too late for the mock. So before Node loads the -// test file, this finds its top-level jest.mock calls with acorn and runs them -// here. As in Jest, a mock factory may only use globals such as `jest`. +// code runs, which would be too late for the mock. Node's own module mocks +// (mock.module) are not yet stable, so this replaces the module's file +// instead. +// +// Before Node loads the test file, this finds its top-level jest.mock calls +// with acorn and runs each factory. It then writes a small module in place of +// the mocked file, which exports what the factory returned. Both the test +// file and the solution import that module. The original file is put back +// when the process exits. As in Jest, a mock factory may only use globals +// such as `jest`. +const MOCKS = Symbol.for('exercism.jest.mocks') +const mocks = new Map>() +Object.assign(globalThis, { [MOCKS]: mocks }) + +function mockModule( + testFile: string, + moduleName: string, + factory?: () => Record +): void { + if (typeof factory !== 'function') { + throw new Error( + `jest.mock('${moduleName}') needs a factory function in this test runner.` + ) + } + + const file = createRequire(testFile).resolve(moduleName) + const original = fs.readFileSync(file) + process.on('exit', () => { + fs.writeFileSync(file, original) + }) + + const exports = factory() + mocks.set(file, exports) + + const names = Object.keys(exports).filter( + (name) => name !== 'default' && /^[A-Za-z_$][\w$]*$/.test(name) + ) + fs.writeFileSync( + file, + [ + `// The test runner wrote this file for jest.mock('${moduleName}').`, + `const mock = globalThis[Symbol.for('exercism.jest.mocks')].get(${JSON.stringify(file)})`, + `export default 'default' in mock ? mock.default : mock`, + ...names.map((name) => `export const ${name} = mock.${name}`), + '', + ].join('\n') + ) +} + function hoistMocks(testFile: string): void { const source = fs.readFileSync(testFile, 'utf8') @@ -225,11 +251,21 @@ function hoistMocks(testFile: string): void { statement.expression.callee.property.type === 'Identifier' && statement.expression.callee.property.name === 'mock' ) - .map((statement) => source.slice(statement.start, statement.end)) + .map((statement) => { + const { arguments: args } = ( + statement as ExpressionStatement & { expression: CallExpression } + ).expression + return `[${args.map((arg) => source.slice(arg.start, arg.end)).join(', ')}]` + }) if (calls.length > 0) { - // Naming the test file lets jest.mock resolve paths from it. - runInThisContext(calls.join('\n'), { filename: testFile }) + // Naming the test file makes any error in a factory point at it. + const argumentLists = runInThisContext(`[${calls.join(',\n')}]`, { + filename: testFile, + }) as [string, () => Record][] + for (const [moduleName, factory] of argumentLists) { + mockModule(testFile, moduleName, factory) + } } } diff --git a/src/reporter.mts b/src/reporter.mts index 77ff9c3..c665e65 100644 --- a/src/reporter.mts +++ b/src/reporter.mts @@ -80,8 +80,8 @@ export default async function* reporter( }) } - // Node loads this reporter before the preloaded setup.mts, so this file - // imports jest-globals.mjs only now, to let setup.mts load it first. + // Node loads this reporter before the preloaded setup.cts, so this file + // imports jest-globals.mjs only now, to let setup.cts load it first. const { loadErrors, testConsole } = await import('./jest-globals.mjs') if (loadErrors.length > 0) { diff --git a/src/setup.cts b/src/setup.cts new file mode 100644 index 0000000..0ff6120 --- /dev/null +++ b/src/setup.cts @@ -0,0 +1,31 @@ +// Runs the track's Jest-style test files on Node's built-in test runner. +// +// bin/run.sh preloads this file with `node --require`, so it runs before the +// test file loads. Node loads the solution and the test file as they are, as +// native ES modules. Jest used to load every file through Babel first. +// +// Before the test file loads, this file: +// +// 1. rewrites the import paths in the test file and the files it imports, so +// Node can find them without a module hook (see imports.ts). +// 2. loads jest-globals.mjs, which provides the Jest API on top of node:test +// and runs the test file's jest.mock calls. +// +// Worker threads started by a solution also run this file, because they +// inherit Node's options. Only the main thread needs it, and loading the +// Jest API would make every worker start much more slowly. +import { isMainThread } from 'node:worker_threads' +import { rewriteImports } from './imports.js' + +if (isMainThread && process.env.TEST_FILE) { + rewriteImports(process.env.TEST_FILE) + + // Jest ran with --colors, which makes chalk colour the messages from + // `expect`. Node has no such option, so this adds the flag to the process's + // arguments, where chalk looks for it, before Jest's packages load. + process.argv.push('--colors') + + // jest-globals.mjs is an ES module, and Node can require it because it has + // no top-level await. + require('./jest-globals.mjs') +} diff --git a/src/setup.mts b/src/setup.mts deleted file mode 100644 index 55893d2..0000000 --- a/src/setup.mts +++ /dev/null @@ -1,48 +0,0 @@ -// Runs the track's Jest-style test files on Node's built-in test runner. -// -// bin/run.sh preloads this file with `node --import`, so it runs before the -// test file loads. Node loads the solution and the test file as they are, as -// native ES modules. Jest used to load every file through Babel first. -// -// This file registers a module hook that does two things: -// -// 1. It makes `import ... from '@jest/globals'` load jest-globals.mjs, which -// provides the Jest API on top of node:test. -// 2. It lets relative imports leave out the `.js` extension, as Jest did -// (`import { twoFer } from './two-fer'`). -// -// Worker threads started by a solution also run this file, because they -// inherit Node's options. They only need the hook, so they don't load the -// Jest API, which would make every worker start much more slowly. -import { registerHooks } from 'node:module' -import { isMainThread } from 'node:worker_threads' - -const jestGlobals = new URL('./jest-globals.mjs', import.meta.url).href - -registerHooks({ - resolve(specifier, context, nextResolve) { - if (specifier === '@jest/globals') { - return { url: jestGlobals, shortCircuit: true } - } - - try { - return nextResolve(specifier, context) - } catch (error) { - if ( - (error as NodeJS.ErrnoException).code === 'ERR_MODULE_NOT_FOUND' && - specifier.startsWith('.') - ) { - return nextResolve(`${specifier}.js`, context) - } - throw error - } - }, -}) - -if (isMainThread) { - // Jest ran with --colors, which makes chalk colour the messages from - // `expect`. Node has no such option, so this adds the flag to the process's - // arguments, where chalk looks for it, before Jest's packages load. - process.argv.push('--colors') - await import(jestGlobals) -} diff --git a/test/fixtures/two-fer/error/empty/expected_results.json b/test/fixtures/two-fer/error/empty/expected_results.json index edab60d..29a265c 100644 --- a/test/fixtures/two-fer/error/empty/expected_results.json +++ b/test/fixtures/two-fer/error/empty/expected_results.json @@ -1,6 +1,6 @@ { "status": "error", - "message": "/two-fer.spec.js:1\nimport { twoFer } from './two-fer';\n ^^^^^^\nSyntaxError: Named export 'twoFer' not found. The requested module './two-fer' is a CommonJS module, which may not support all module.exports as named exports.\nCommonJS modules can always be imported via the default export, for example using:\n\nimport pkg from './two-fer';\nconst { twoFer } = pkg;\n", + "message": "/two-fer.spec.js:1\nimport { twoFer } from './two-fer.js';\n ^^^^^^\nSyntaxError: Named export 'twoFer' not found. The requested module './two-fer.js' is a CommonJS module, which may not support all module.exports as named exports.\nCommonJS modules can always be imported via the default export, for example using:\n\nimport pkg from './two-fer.js';\nconst { twoFer } = pkg;\n", "tests": [], "version": 3 } \ No newline at end of file From 4e29cbb784a74dc03e8606ca4f027192dff1cca8 Mon Sep 17 00:00:00 2001 From: iHiD <286476+iHiD@users.noreply.github.com> Date: Tue, 24 Nov 2026 20:59:08 +0900 Subject: [PATCH 4/4] Find imports with a module hook, and preload core-js Node's synchronous module hooks (module.registerHooks) are marked "Release candidate", which is now acceptable. setup.cts registers a resolve hook, so Node finds @jest/globals and files imported without their extension, as Jest did. This replaces src/imports.ts, which parsed the test file and every file it imported, and rewrote their import paths on disk. jest.mock now uses a load hook, which hands Node a small module in place of the mocked file, so the file itself is never changed. Errors about an import now quote the path as written in the file, as they did with Jest. Jest's Babel preset added a core-js polyfill for each built-in a file used that Node lacked. setup.cts now loads the 15 core-js modules for the stable built-ins missing from Node 24.18 on every run, with no parsing, such as Math.sumPrecise and Uint8Array.fromBase64. The list was generated with core-js-compat, and the comment above it says how to regenerate it. Co-authored-by: iHiD <286476+iHiD@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 --- package.json | 2 + pnpm-lock.yaml | 6 + src/imports.ts | 179 ------------------ src/jest-globals.mts | 46 +++-- src/setup.cts | 81 +++++++- .../two-fer/error/empty/expected_results.json | 2 +- 6 files changed, 108 insertions(+), 208 deletions(-) delete mode 100644 src/imports.ts diff --git a/package.json b/package.json index 3f6b244..f82843c 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "@jest/console": "^30.5.2", "acorn": "^8.15.0", "chalk": "^6.0.0", + "core-js": "^3.49.0", "expect": "^30.5.2", "jest-mock": "^30.5.2", "shelljs": "^0.10.0" @@ -39,6 +40,7 @@ "@tsconfig/node22": "^22.0.2", "@types/node": "^22.16.5", "@types/shelljs": "^0.10.0", + "core-js-compat": "^3.49.0", "eslint": "^9.31.0", "prettier": "^3.6.2", "rimraf": "^6.0.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c0c8590..cd7d1c4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -17,6 +17,9 @@ importers: chalk: specifier: ^6.0.0 version: 6.0.1 + core-js: + specifier: ^3.49.0 + version: 3.49.0 expect: specifier: ^30.5.2 version: 30.5.2 @@ -39,6 +42,9 @@ importers: '@types/shelljs': specifier: ^0.10.0 version: 0.10.0 + core-js-compat: + specifier: ^3.49.0 + version: 3.49.0 eslint: specifier: ^9.31.0 version: 9.31.0 diff --git a/src/imports.ts b/src/imports.ts deleted file mode 100644 index 7c2018f..0000000 --- a/src/imports.ts +++ /dev/null @@ -1,179 +0,0 @@ -// Rewrites the import paths in the test file, and in the files it imports, so -// that Node's own module loader can find every file. setup.cts calls this -// before the test file loads. -// -// Jest found these files itself. Node only finds a relative import if it -// names the file in full, and only finds `@jest/globals` in a node_modules -// folder. A module hook could fix both while the files load, but Node's hooks -// are not yet stable. So this changes the paths in the files instead: -// -// - `'./two-fer'` becomes `'./two-fer.js'` if two-fer.js exists, and -// `'./lib'` becomes `'./lib/index.js'` if lib is a folder. The track's -// files name the file in full, but solutions to earlier versions of the -// exercises, and many students' own files, leave out the extension. -// - `'@jest/globals'` becomes the path of the runner's jest-globals.mjs. So -// solutions still can't import any of the runner's packages. -// -// The files are parsed with acorn, so text in strings and comments is never -// changed. A file that fails to parse is left alone, and Node will report the -// syntax error when it loads the file. -import { parse } from 'acorn' -import type { Node } from 'acorn' -import fs from 'node:fs' -import path from 'node:path' -import { pathToFileURL } from 'node:url' - -const JEST_GLOBALS = path.join(__dirname, 'jest-globals.mjs') - -interface Edit { - start: number - end: number - text: string -} - -type StringLiteral = Node & { type: 'Literal'; value: string; raw: string } - -export function rewriteImports(entryFile: string): void { - const visited = new Set() - - function visit(file: string): void { - if (visited.has(file)) { - return - } - visited.add(file) - - const source = fs.readFileSync(file, 'utf8') - let program: Node - try { - program = parse(source, { - ecmaVersion: 'latest', - sourceType: 'module', - allowHashBang: true, - }) - } catch { - return - } - - const edits: Edit[] = [] - for (const { literal, isRequire } of importPaths(program)) { - const specifier = literal.value - let replacement: string | undefined - - if (specifier === '@jest/globals') { - replacement = isRequire - ? JEST_GLOBALS - : pathToFileURL(JEST_GLOBALS).href - } else if (specifier.startsWith('./') || specifier.startsWith('../')) { - const target = path.resolve(path.dirname(file), specifier) - const found = findFile(target) - if (found) { - visit(found) - // require() finds a file without its extension by itself. - if (!isRequire && found !== target) { - replacement = specifier + found.slice(target.length) - } - } - } - - if (replacement !== undefined) { - const quote = literal.raw[0] - edits.push({ - start: literal.start, - end: literal.end, - text: `${quote}${replacement}${quote}`, - }) - } - } - - if (edits.length === 0) { - return - } - - let rewritten = source - for (const edit of edits.sort((a, b) => b.start - a.start)) { - rewritten = - rewritten.slice(0, edit.start) + edit.text + rewritten.slice(edit.end) - } - fs.writeFileSync(file, rewritten) - } - - visit(path.resolve(entryFile)) -} - -/** Finds the file Jest would load for a relative import, as Jest did. */ -function findFile(target: string): string | undefined { - for (const candidate of [ - target, - `${target}.js`, - path.join(target, 'index.js'), - ]) { - if (fs.statSync(candidate, { throwIfNoEntry: false })?.isFile()) { - return candidate - } - } - return undefined -} - -/** - * The string paths in import and export declarations, in `import()`, and in - * `require()` calls. - */ -function importPaths( - program: Node -): { literal: StringLiteral; isRequire: boolean }[] { - const found: { literal: StringLiteral; isRequire: boolean }[] = [] - - function walk(node: Node): void { - const value = node as Node & Record - - if ( - node.type === 'ImportDeclaration' || - node.type === 'ExportNamedDeclaration' || - node.type === 'ExportAllDeclaration' || - node.type === 'ImportExpression' - ) { - if (isStringLiteral(value.source)) { - found.push({ literal: value.source, isRequire: false }) - } - } else if (node.type === 'CallExpression') { - const callee = value.callee as Node & { name?: string } - const [first] = value.arguments as Node[] - if ( - callee.type === 'Identifier' && - callee.name === 'require' && - isStringLiteral(first) - ) { - found.push({ literal: first, isRequire: true }) - } - } - - for (const child of Object.values(value)) { - if (Array.isArray(child)) { - child.forEach((item) => { - if (isNode(item)) walk(item) - }) - } else if (isNode(child)) { - walk(child) - } - } - } - - walk(program) - return found -} - -function isNode(value: unknown): value is Node { - return ( - typeof value === 'object' && - value !== null && - typeof (value as { type?: unknown }).type === 'string' - ) -} - -function isStringLiteral(value: unknown): value is StringLiteral { - return ( - isNode(value) && - value.type === 'Literal' && - typeof (value as { value?: unknown }).value === 'string' - ) -} diff --git a/src/jest-globals.mts b/src/jest-globals.mts index 315ced1..4318c7c 100644 --- a/src/jest-globals.mts +++ b/src/jest-globals.mts @@ -1,7 +1,7 @@ // Provides the Jest API used by the track's test files, on top of node:test, // Jest's own `expect` package and `jest-mock`. setup.cts loads it before the // test file, and points the test file's `import ... from '@jest/globals'` at -// it (see imports.ts). This file also: +// it. This file also: // // 1. makes the API available as globals, as Jest did. // 2. replaces `console` with Jest's BufferedConsole, which records each @@ -15,7 +15,7 @@ import type { CallExpression, ExpressionStatement, Statement } from 'acorn' import { expect } from 'expect' import { ModuleMocker } from 'jest-mock' import fs from 'node:fs' -import { createRequire } from 'node:module' +import { createRequire, registerHooks } from 'node:module' import { after, afterEach as nodeAfterEach, @@ -24,6 +24,7 @@ import { describe as nodeDescribe, test as nodeTest, } from 'node:test' +import { pathToFileURL } from 'node:url' import { runInThisContext } from 'node:vm' /** Collects every console message, for the reporter. */ @@ -177,19 +178,30 @@ Object.assign(globalThis, { // babel-plugin-jest-hoist), so the mock replaced the module before anything // imported it. Native ES modules load all their imports before any of their // code runs, which would be too late for the mock. Node's own module mocks -// (mock.module) are not yet stable, so this replaces the module's file -// instead. +// (mock.module) are not yet stable, so this uses a module hook instead. // // Before Node loads the test file, this finds its top-level jest.mock calls -// with acorn and runs each factory. It then writes a small module in place of -// the mocked file, which exports what the factory returned. Both the test -// file and the solution import that module. The original file is put back -// when the process exits. As in Jest, a mock factory may only use globals -// such as `jest`. +// with acorn and runs each factory. When the test file or the solution then +// imports the mocked file, the hook hands Node a small module in its place, +// which exports what the factory returned. The file itself is never changed. +// As in Jest, a mock factory may only use globals such as `jest`. const MOCKS = Symbol.for('exercism.jest.mocks') const mocks = new Map>() Object.assign(globalThis, { [MOCKS]: mocks }) +/** The source of the module that replaces each mocked file, by URL. */ +const mockSources = new Map() + +registerHooks({ + load(url, context, nextLoad) { + const source = mockSources.get(url) + if (source === undefined) { + return nextLoad(url, context) + } + return { format: 'module', source, shortCircuit: true } + }, +}) + function mockModule( testFile: string, moduleName: string, @@ -201,23 +213,17 @@ function mockModule( ) } - const file = createRequire(testFile).resolve(moduleName) - const original = fs.readFileSync(file) - process.on('exit', () => { - fs.writeFileSync(file, original) - }) - + const url = pathToFileURL(createRequire(testFile).resolve(moduleName)).href const exports = factory() - mocks.set(file, exports) + mocks.set(url, exports) const names = Object.keys(exports).filter( (name) => name !== 'default' && /^[A-Za-z_$][\w$]*$/.test(name) ) - fs.writeFileSync( - file, + mockSources.set( + url, [ - `// The test runner wrote this file for jest.mock('${moduleName}').`, - `const mock = globalThis[Symbol.for('exercism.jest.mocks')].get(${JSON.stringify(file)})`, + `const mock = globalThis[Symbol.for('exercism.jest.mocks')].get(${JSON.stringify(url)})`, `export default 'default' in mock ? mock.default : mock`, ...names.map((name) => `export const ${name} = mock.${name}`), '', diff --git a/src/setup.cts b/src/setup.cts index 0ff6120..293508a 100644 --- a/src/setup.cts +++ b/src/setup.cts @@ -6,20 +6,55 @@ // // Before the test file loads, this file: // -// 1. rewrites the import paths in the test file and the files it imports, so -// Node can find them without a module hook (see imports.ts). +// 1. registers a module hook, so Node finds `@jest/globals` and files +// imported without their extension, as Jest did. // 2. loads jest-globals.mjs, which provides the Jest API on top of node:test // and runs the test file's jest.mock calls. +// 3. loads the core-js polyfills for built-ins missing from the image's Node. // // Worker threads started by a solution also run this file, because they -// inherit Node's options. Only the main thread needs it, and loading the -// Jest API would make every worker start much more slowly. +// inherit Node's options. They need the hook and the polyfills. Loading the +// Jest API would make every worker start much more slowly, so only the main +// thread loads it. +import { registerHooks } from 'node:module' +import path from 'node:path' +import { pathToFileURL } from 'node:url' import { isMainThread } from 'node:worker_threads' -import { rewriteImports } from './imports.js' -if (isMainThread && process.env.TEST_FILE) { - rewriteImports(process.env.TEST_FILE) +const JEST_GLOBALS = path.join(__dirname, 'jest-globals.mjs') + +// Jest found these imports itself. Node only finds `@jest/globals` in a +// node_modules folder, and a relative import only if it names the file in +// full. The track's test files name every file in full, but solutions to +// earlier versions of the exercises, and many students' own files, leave out +// the extension. So if Node can't find a relative import, this tries it with +// `.js` and then as a folder with `index.js`, as Jest did. Solutions still +// can't import any of the runner's other packages. +registerHooks({ + resolve(specifier, context, nextResolve) { + if (specifier === '@jest/globals') { + return { url: pathToFileURL(JEST_GLOBALS).href, shortCircuit: true } + } + try { + return nextResolve(specifier, context) + } catch (error) { + if (!specifier.startsWith('./') && !specifier.startsWith('../')) { + throw error + } + for (const candidate of [`${specifier}.js`, `${specifier}/index.js`]) { + try { + return nextResolve(candidate, context) + } catch { + // Try the next one. If none exists, report the original error. + } + } + throw error + } + }, +}) + +if (isMainThread && process.env.TEST_FILE) { // Jest ran with --colors, which makes chalk colour the messages from // `expect`. Node has no such option, so this adds the flag to the process's // arguments, where chalk looks for it, before Jest's packages load. @@ -27,5 +62,35 @@ if (isMainThread && process.env.TEST_FILE) { // jest-globals.mjs is an ES module, and Node can require it because it has // no top-level await. - require('./jest-globals.mjs') + require(JEST_GLOBALS) +} + +// Jest compiled each file with Babel, which added a core-js polyfill for each +// built-in that the file used and the image's Node lacked. Loading the few +// polyfills this Node needs on every run is cheaper than finding which ones +// each file uses. +// +// The list holds core-js's stable features missing from Node 24.18 (see the +// Dockerfile). After changing either version, regenerate it with: +// +// node -p "require('core-js-compat')({ targets: { node: '24.18' }, modules: ['core-js/stable'], version: require('core-js/package.json').version }).list" +const CORE_JS_MODULES = [ + 'es.iterator.concat', + 'es.map.get-or-insert', + 'es.map.get-or-insert-computed', + 'es.math.sum-precise', + 'es.async-iterator.async-dispose', + 'es.uint8-array.from-base64', + 'es.uint8-array.from-hex', + 'es.uint8-array.set-from-base64', + 'es.uint8-array.set-from-hex', + 'es.uint8-array.to-base64', + 'es.uint8-array.to-hex', + 'es.weak-map.get-or-insert', + 'es.weak-map.get-or-insert-computed', + 'web.self', + 'web.structured-clone', +] +for (const name of CORE_JS_MODULES) { + require(`core-js/modules/${name}`) } diff --git a/test/fixtures/two-fer/error/empty/expected_results.json b/test/fixtures/two-fer/error/empty/expected_results.json index 29a265c..edab60d 100644 --- a/test/fixtures/two-fer/error/empty/expected_results.json +++ b/test/fixtures/two-fer/error/empty/expected_results.json @@ -1,6 +1,6 @@ { "status": "error", - "message": "/two-fer.spec.js:1\nimport { twoFer } from './two-fer.js';\n ^^^^^^\nSyntaxError: Named export 'twoFer' not found. The requested module './two-fer.js' is a CommonJS module, which may not support all module.exports as named exports.\nCommonJS modules can always be imported via the default export, for example using:\n\nimport pkg from './two-fer.js';\nconst { twoFer } = pkg;\n", + "message": "/two-fer.spec.js:1\nimport { twoFer } from './two-fer';\n ^^^^^^\nSyntaxError: Named export 'twoFer' not found. The requested module './two-fer' is a CommonJS module, which may not support all module.exports as named exports.\nCommonJS modules can always be imported via the default export, for example using:\n\nimport pkg from './two-fer';\nconst { twoFer } = pkg;\n", "tests": [], "version": 3 } \ No newline at end of file