wallabyjs / public

Repository for Wallaby.js questions and issues
http://wallabyjs.com
760 stars 45 forks source link

Failed to instrument if the test file contains with { type: 'json' } #3333

Closed ramaghanta closed 8 months ago

ramaghanta commented 8 months ago

Issue description or question

Wallaby isn't working if I have with { type: 'json' } syntax in my test file. Here's a sample code and the error from Wallaby console.

import { strict as assert } from 'node:assert';
import { describe, it } from '@jest/globals';
import schema from './schema' with { type: 'json' };

describe('test', () => {
  it('test', () => {
    assert(true);
  });
});
Runtime error: Failed to instrument src/test.spec.ts
  1 | import { describe, it } from '@jest/globals';
  2 | import { strict as assert } from 'node:assert';
> 3 | import schema from './schema' with { type: 'json' };
    |                               ^ SyntaxError: Unexpected token (3:30)
  4 | describe('test', () => {
  5 |     it('test', () => {
  6 |         assert(true);
    at ScriptTransformer.transformSourceAsync (./node_modules/@jest/transform/build/ScriptTransformer.js:599:19)
    at ScriptTransformer._transformAndBuildScriptAsync (./node_modules/@jest/transform/build/ScriptTransformer.js:639:35)
    at ScriptTransformer.transformAsync (./node_modules/@jest/transform/build/ScriptTransformer.js:703:14)
    at Runtime.transformFileAsync (./node_modules/jest-runtime/build/index.js:1484:29)
    at Runtime.loadEsmModule (./node_modules/jest-runtime/build/index.js:493:31)
    at Runtime.unstable_importModule (./node_modules/jest-runtime/build/index.js:721:20)
    at jestAdapter (./node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:75:5)
    at runTestInternal (./node_modules/jest-runner/build/runTest.js:367:16)
    at runTest (./node_modules/jest-runner/build/runTest.js:444:34)

Wallaby diagnostics report

{
  editorVersion: 'WebStorm 2023.3.3',
  pluginVersion: '1.0.284',
  editorType: 'IntelliJ',
  osVersion: 'darwin 23.3.0',
  nodeVersion: 'v20.11.0',
  coreVersion: '1.0.1525',
  checksum: 'MzIxMjhlMDg0NWNkNjI3YWQ3ZTNhYWEyYWI3Y2Y1MjksMTcwODMwMDgwMDAwMCww',
  config: {
    diagnostics: {
      jest: {
        config: {
          configs: [
            {
              automock: false,
              cache: true,
              cacheDirectory: '/private/var/folders/z9/1k_d7mc56gxfw9n502ynlyh80000gs/T/jest_e1',
              clearMocks: false,
              collectCoverageFrom: [ 'src/**' ],
              coverageDirectory: '<homeDir>/TestProjects/awsS3Test/coverage',
              coveragePathIgnorePatterns: [ '/node_modules/' ],
              cwd: '<homeDir>/TestProjects/awsS3Test',
              dependencyExtractor: undefined,
              detectLeaks: false,
              detectOpenHandles: false,
              displayName: undefined,
              errorOnDeprecated: false,
              extensionsToTreatAsEsm: [ '.ts' ],
              fakeTimers: { enableGlobally: false },
              filter: undefined,
              forceCoverageMatch: [],
              globalSetup: undefined,
              globalTeardown: undefined,
              globals: {},
              haste: { computeSha1: false, enableSymlinks: false, forceNodeFilesystemAPI: true, throwOnModuleCollision: false },
              id: '4872f9f93cf1255028cc6867a4d86e92',
              injectGlobals: true,
              moduleDirectories: [ 'node_modules' ],
              moduleFileExtensions: [
                'js',   'mjs',
                'cjs',  'jsx',
                'ts',   'tsx',
                'json', 'node'
              ],
              moduleNameMapper: [],
              modulePathIgnorePatterns: [],
              modulePaths: undefined,
              openHandlesTimeout: 1000,
              prettierPath: 'prettier',
              resetMocks: false,
              resetModules: false,
              resolver: undefined,
              restoreMocks: false,
              rootDir: '<homeDir>/TestProjects/awsS3Test',
              roots: [ '<homeDir>/TestProjects/awsS3Test' ],
              runner: '<homeDir>/TestProjects/awsS3Test/node_modules/jest-runner/build/index.js',
              runtime: undefined,
              sandboxInjectedGlobals: [],
              setupFiles: [ '<homeDir>/TestProjects/awsS3Test/node_modules/dotenv/config.js' ],
              setupFilesAfterEnv: [],
              skipFilter: false,
              skipNodeResolution: undefined,
              slowTestThreshold: 5,
              snapshotFormat: { escapeString: false, printBasicPrototype: false },
              snapshotResolver: undefined,
              snapshotSerializers: [],
              testEnvironment: '<homeDir>/TestProjects/awsS3Test/node_modules/jest-environment-node/build/index.js',
              testEnvironmentOptions: {},
              testLocationInResults: false,
              testMatch: [ '<homeDir>/TestProjects/awsS3Test/src/**/*.spec.ts' ],
              testPathIgnorePatterns: [ '/node_modules/' ],
              testRegex: [],
              testRunner: '<homeDir>/TestProjects/awsS3Test/node_modules/jest-circus/runner.js',
              transform: [ [ '^.+\\.ts$', '<homeDir>/TestProjects/awsS3Test/node_modules/ts-jest/dist/index.js', { isolatedModules: true, diagnostics: false, useESM: true } ] ],
              transformIgnorePatterns: [ '/node_modules/', '\\.pnp\\.[^\\/]+$' ],
              unmockedModulePathPatterns: undefined,
              watchPathIgnorePatterns: []
            }
          ],
          globalConfig: {
            bail: 0,
            changedFilesWithAncestor: false,
            changedSince: undefined,
            ci: false,
            collectCoverage: false,
            collectCoverageFrom: [ 'src/**' ],
            coverageDirectory: '<homeDir>/TestProjects/awsS3Test/coverage',
            coverageProvider: 'v8',
            coverageReporters: [ 'json', 'text', 'lcov', 'clover' ],
            coverageThreshold: undefined,
            detectLeaks: false,
            detectOpenHandles: false,
            errorOnDeprecated: false,
            expand: false,
            filter: undefined,
            findRelatedTests: false,
            forceExit: false,
            globalSetup: undefined,
            globalTeardown: undefined,
            json: false,
            lastCommit: false,
            listTests: false,
            logHeapUsage: false,
            maxConcurrency: 5,
            maxWorkers: 9,
            noSCM: undefined,
            noStackTrace: false,
            nonFlagArgs: undefined,
            notify: false,
            notifyMode: 'failure-change',
            onlyChanged: false,
            onlyFailures: false,
            openHandlesTimeout: 1000,
            outputFile: undefined,
            passWithNoTests: false,
            projects: [],
            randomize: undefined,
            replname: undefined,
            reporters: undefined,
            rootDir: '<homeDir>/TestProjects/awsS3Test',
            runInBand: undefined,
            runTestsByPath: false,
            seed: 594689020,
            shard: undefined,
            showSeed: undefined,
            silent: undefined,
            skipFilter: false,
            snapshotFormat: { escapeString: false, printBasicPrototype: false },
            testFailureExitCode: 1,
            testNamePattern: undefined,
            testPathPattern: '',
            testResultsProcessor: undefined,
            testSequencer: '<homeDir>/TestProjects/awsS3Test/node_modules/@jest/test-sequencer/build/index.js',
            testTimeout: undefined,
            updateSnapshot: 'new',
            useStderr: false,
            verbose: undefined,
            watch: false,
            watchAll: false,
            watchPlugins: undefined,
            watchman: true,
            workerIdleMemoryLimit: undefined,
            workerThreads: false
          },
          hasDeprecationWarnings: false,
          wallaby: {
            roots: [],
            watchPathIgnorePatterns: [ '/node_modules/', '\\./dist/|\\./build/|\\./coverage/|\\./git/|/\\..+/', '/private/var/folders/z9/1k_d7mc56gxfw9n502ynlyh80000gs/T/jest_e1', '\\./coverage' ],
            testPathIgnorePatterns: [ '/node_modules/', '\\./dist/|\\./build/|\\./coverage/|\\./git/|/\\..+/', '/private/var/folders/z9/1k_d7mc56gxfw9n502ynlyh80000gs/T/jest_e1', '\\./coverage' ],
            testMatch: [ 'src/**/*.spec.ts' ],
            testRegex: []
          }
        }
      }
    },
    testFramework: { version: 'jest@24.8.0', configurator: 'jest@24.8.0', reporter: 'jest@24.8.0', starter: 'jest@24.8.0', autoDetected: true },
    filesWithCoverageCalculated: [ 'src/**', 'src/**' ],
    filesWithNoCoverageCalculated: [],
    globalSetup: false,
    dot: true,
    files: [
      { pattern: '/node_modules/', regexp: /\/node_modules\//, ignore: true, trigger: true, load: true, file: true, test: true },
      {
        pattern: '\\./dist/|\\./build/|\\./coverage/|\\./git/|/\\..+/',
        regexp: /\.\/dist\/|\.\/build\/|\.\/coverage\/|\.\/git\/|\/\..+\//,
        ignore: true,
        trigger: true,
        load: true,
        file: true,
        test: true
      },
      {
        pattern: '/private/var/folders/z9/1k_d7mc56gxfw9n502ynlyh80000gs/T/jest_e1',
        regexp: /\/private\/var\/folders\/z9\/1k_d7mc56gxfw9n502ynlyh80000gs\/T\/jest_e1/,
        ignore: true,
        trigger: true,
        load: true,
        file: true,
        test: true
      },
      { pattern: '\\./coverage', regexp: /\.\/coverage/, ignore: true, trigger: true, load: true, file: true, test: true },
      { pattern: '**/**', ignore: false, trigger: true, load: true, order: 1 },
      { pattern: 'src/**/*.spec.ts', ignore: true, trigger: true, load: true, file: true }
    ],
    captureConsoleLog: true,
    tests: [
      { pattern: '/node_modules/', regexp: /\/node_modules\//, ignore: true, trigger: true, load: true, test: true, file: false },
      {
        pattern: '\\./dist/|\\./build/|\\./coverage/|\\./git/|/\\..+/',
        regexp: /\.\/dist\/|\.\/build\/|\.\/coverage\/|\.\/git\/|\/\..+\//,
        ignore: true,
        trigger: true,
        load: true,
        test: true,
        file: false
      },
      {
        pattern: '/private/var/folders/z9/1k_d7mc56gxfw9n502ynlyh80000gs/T/jest_e1',
        regexp: /\/private\/var\/folders\/z9\/1k_d7mc56gxfw9n502ynlyh80000gs\/T\/jest_e1/,
        ignore: true,
        trigger: true,
        load: true,
        test: true,
        file: false
      },
      { pattern: '\\./coverage', regexp: /\.\/coverage/, ignore: true, trigger: true, load: true, test: true, file: false },
      { pattern: 'src/**/*.spec.ts', ignore: false, trigger: true, load: true, test: true, order: 2 }
    ],
    runAllTestsInAffectedTestFile: false,
    updateNoMoreThanOneSnapshotPerTestFileRun: false,
    compilers: {},
    logLimits: { inline: { depth: 5, elements: 5000 }, values: { default: { stringLength: 200 }, autoExpand: { elements: 5000, stringLength: 8192, depth: 10 } } },
    preprocessors: {},
    maxConsoleMessagesPerTest: 100,
    autoConsoleLog: true,
    delays: { run: 0, edit: 100, update: 0 },
    workers: { initial: 0, regular: 0, recycle: false },
    teardown: undefined,
    hints: {
      ignoreCoverage: '__REGEXP /ignore coverage|istanbul ignore|c8 ignore/',
      ignoreCoverageForFile: '__REGEXP /ignore file coverage/',
      commentAutoLog: '?',
      testFileSelection: { include: '__REGEXP /file\\.only/', exclude: '__REGEXP /file\\.skip/' }
    },
    automaticTestFileSelection: true,
    runSelectedTestsOnly: false,
    mapConsoleMessagesStackTrace: false,
    extensions: {},
    env: {
      type: 'node',
      params: {},
      runner: '<homeDir>/.nvm/versions/node/v20.11.0/bin/node',
      viewportSize: { width: 800, height: 600 },
      options: { width: 800, height: 600 },
      bundle: true
    },
    reportUnhandledPromises: true,
    slowTestThreshold: 75,
    lowCoverageThreshold: 80,
    runAllTestsWhenNoAffectedTests: false,
    configCode: 'auto.detect#1058454379'
  },
  packageJSON: {
    dependencies: {
      '@checkdigit/hash': '^2.0.2',
      '@checkdigit/time': '^2.0.0',
      '@checkdigit/typescript-config': '^6.0.0',
      'aws-sdk': '^2.1559.0',
      moment: '^2.30.1',
      rimraf: '^5.0.5',
      'ts-node': '^10.9.2'
    },
    devDependencies: { '@checkdigit/jest-config': '^6.0.0' }
  },
  fs: { numberOfFiles: 7 },
  debug: [
    '2024-02-15T22:20:34.293Z project waiting for initial run signal\n',
    '2024-02-15T22:20:34.298Z config Attempting automatic configuration for angular\n',
    '2024-02-15T22:20:34.299Z angular/cli config Angular CLI not found.\n',
    '2024-02-15T22:20:34.299Z config Finished attempting automatic configuration for angular (1ms)\n',
    '2024-02-15T22:20:34.299Z config Attempting automatic configuration for jest\n',
    '2024-02-15T22:20:34.342Z jest/config Detected Jest.\n',
    '2024-02-15T22:20:34.343Z jest/config Configured Jest.\n',
    '2024-02-15T22:20:34.343Z config Finished attempting automatic configuration for jest (44ms)\n',
    '2024-02-15T22:20:34.343Z project Wallaby Node version: v20.11.0\n',
    '2024-02-15T22:20:34.343Z project Wallaby config: <homeDir>/TestProjects/awsS3Test/auto.detect\n',
    '2024-02-15T22:20:34.367Z fs File system starting\n',
    '2024-02-15T22:20:34.379Z fs File system scan completed\n',
    '2024-02-15T22:20:34.381Z project File cache: <homeDir>/Library/Caches/JetBrains/WebStorm2023.3/wallaby/projects/e833528df14c7f79\n',
    '2024-02-15T22:20:34.384Z uiService Listening port 51237\n',
    '2024-02-15T22:20:34.387Z workers Parallelism for initial run: 8, for regular run: 4\n',
    '2024-02-15T22:20:34.387Z workers Starting run worker instance #0\n',
    '2024-02-15T22:20:34.387Z workers Starting run worker instance #1\n',
    '2024-02-15T22:20:34.387Z workers Starting run worker instance #2\n',
    '2024-02-15T22:20:34.387Z workers Starting run worker instance #3\n',
    '2024-02-15T22:20:34.387Z workers Starting run worker instance #4\n',
    '2024-02-15T22:20:34.387Z workers Starting run worker instance #5\n',
    '2024-02-15T22:20:34.387Z workers Starting run worker instance #6\n',
    '2024-02-15T22:20:34.387Z workers Starting run worker instance #7\n',
    '2024-02-15T22:20:34.388Z workers Web server is listening at 51227\n',
    '2024-02-15T22:20:34.388Z project File cache requires some updates, waiting required files from IDE\n',
    '2024-02-15T22:20:34.413Z project Stopping process pool\n',
    '2024-02-15T22:20:34.417Z project Test run started; run priority: 3\n',
    '2024-02-15T22:20:34.417Z project Running all tests\n',
    '2024-02-15T22:20:34.418Z workers Starting test run, priority: 3\n',
    '2024-02-15T22:20:34.418Z nodeRunner Starting sandbox [worker #0, session #bahn1]\n',
    '2024-02-15T22:20:34.418Z nodeRunner Preparing sandbox [worker #0, session #bahn1]\n',
    '2024-02-15T22:20:34.484Z workers Started run worker instance (delayed) #3\n',
    '2024-02-15T22:20:34.484Z workers Started run worker instance (delayed) #0\n',
    '2024-02-15T22:20:34.484Z nodeRunner Prepared sandbox [worker #0, session #bahn1]\n',
    '2024-02-15T22:20:34.484Z workers [worker #0, session #bahn1] Running tests in sandbox\n',
    '2024-02-15T22:20:34.488Z workers Started run worker instance (delayed) #7\n',
    '2024-02-15T22:20:34.489Z workers Started run worker instance (delayed) #4\n',
    '2024-02-15T22:20:34.491Z workers Started run worker instance (delayed) #2\n',
    '2024-02-15T22:20:34.495Z workers Started run worker instance (delayed) #1\n',
    '2024-02-15T22:20:34.497Z workers Started run worker instance (delayed) #5\n',
    '2024-02-15T22:20:34.504Z workers Started run worker instance (delayed) #6\n',
    "2024-02-15T22:20:34.568Z workers 'Scheduling Jest Test Run (bahn1): 2024-02-15T22:20:34.565Z'\n",
    '2024-02-15T22:20:34.830Z workers Sandbox (active) [bahn1] error: Failed to instrument src/test.spec.ts\n' +
      "  1 | import { describe, it } from '@jest/globals';\n" +
      "  2 | import { strict as assert } from 'node:assert';\n" +
      "> 3 | import schema from './schema' with { type: 'json' };\n" +
      '    |                               ^ SyntaxError: Unexpected token (3:30)\n' +
      "  4 | describe('test', () => {\n" +
      "  5 |     it('test', () => {\n" +
      '  6 |         assert(true);\n' +
      '    at ScriptTransformer.transformSourceAsync (./node_modules/@jest/transform/build/ScriptTransformer.js:599:19)\n' +
      '    at ScriptTransformer._transformAndBuildScriptAsync (./node_modules/@jest/transform/build/ScriptTransformer.js:639:35)\n' +
      '    at ScriptTransformer.transformAsync (./node_modules/@jest/transform/build/ScriptTransformer.js:703:14)\n' +
      '    at Runtime.transformFileAsync (./node_modules/jest-runtime/build/index.js:1484:29)\n' +
      '    at Runtime.loadEsmModule (./node_modules/jest-runtime/build/index.js:493:31)\n' +
      '    at Runtime.unstable_importModule (./node_modules/jest-runtime/build/index.js:721:20)\n' +
      '    at jestAdapter (./node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:75:5)\n' +
      '    at runTestInternal (./node_modules/jest-runner/build/runTest.js:367:16)\n' +
      '    at runTest (./node_modules/jest-runner/build/runTest.js:444:34)\n',
    '2024-02-15T22:20:34.831Z workers [bahn1] Run 0 test(s), skipped 0 test(s)\n',
    "2024-02-15T22:20:34.831Z workers 'Jest Test Run Complete (bahn1): 2024-02-15T22:20:34.831Z'\n",
    '2024-02-15T22:20:34.832Z workers [bahn1] Sandbox is responsive, closing it\n',
    '2024-02-15T22:20:34.832Z workers Failed to map the stack to user code, entry message: Failed to instrument src/test.spec.ts\n' +
      "  1 | import { describe, it } from '@jest/globals';\n" +
      "  2 | import { strict as assert } from 'node:assert';\n" +
      "> 3 | import schema from './schema' with { type: 'json' };\n" +
      '    |                               ^ SyntaxError: Unexpected token (3:30)\n' +
      "  4 | describe('test', () => {\n" +
      "  5 |     it('test', () => {\n" +
      '  6 |         assert(true);, stack: Error: Failed to instrument src/test.spec.ts\n' +
      "  1 | import { describe, it } from '@jest/globals';\n" +
      "  2 | import { strict as assert } from 'node:assert';\n" +
      "> 3 | import schema from './schema' with { type: 'json' };\n" +
      '    |                               ^ SyntaxError: Unexpected token (3:30)\n' +
      "  4 | describe('test', () => {\n" +
      "  5 |     it('test', () => {\n" +
      '  6 |         assert(true);\n' +
      '    at Object.formatInstrumentationError (<homeDir>/Library/Caches/JetBrains/WebStorm2023.3/wallaby/wallaby/server.js:507:99682)\n' +
      '    at i (<homeDir>/Library/Caches/JetBrains/WebStorm2023.3/wallaby/wallaby/runners/node/jest@24.8.0/initializer.js:36:15236)\n' +
      '    at l.processAsync (<homeDir>/Library/Caches/JetBrains/WebStorm2023.3/wallaby/wallaby/runners/node/jest@24.8.0/initializer.js:36:17385)\n' +
      '    at ScriptTransformer.transformSourceAsync (<homeDir>/TestProjects/awsS3Test/node_modules/@jest/transform/build/ScriptTransformer.js:599:19)\n' +
      '    at ScriptTransformer._transformAndBuildScriptAsync (/Users/ra\n',
    '2024-02-15T22:20:34.833Z project Test run finished\n',
    '2024-02-15T22:20:34.833Z project Processed console.log entries\n',
    '2024-02-15T22:20:34.833Z project Processed loading sequences\n',
    '2024-02-15T22:20:34.833Z project Processed executed tests\n',
    '2024-02-15T22:20:34.833Z project Processed code coverage\n',
    '2024-02-15T22:20:34.836Z project Test run result processed and sent to IDE\n'
  ]
}
ramaghanta commented 8 months ago

Just to add, npm test works fine in the console with "jest --coverage=false"

smcenlly commented 8 months ago

We tried setting up a sample project based on your diagnostics report and it's working for us. Can you please see if our sample works for you by cloning it, installing dependencies with npm install and then starting Wallaby?

We're using the same version of node, so there's no reason it shouldn't work.

If it works, can you please compare our sample project to your project? It may identify why Wallaby is not working for you.

If that doesn't help, can you please either update our repo with your configuration, or else provide a sample repo that has your problem (i.e. works from the jest CLI but not with Wallaby)?

adcreare commented 8 months ago

Adding extensionsToTreatAsEsm: [ '.ts' ], to the jest.config.js seems to trigger the problem on the sample project (https://github.com/wallabyjs/wallaby-3333) .

smcenlly commented 8 months ago

I'm not getting that problem. My jest.config.js now looks like this:

export default {
  transform: {
    "^.+\\.tsx?$": [
      "ts-jest",
      { isolatedModules: true, diagnostics: false, useESM: true },
    ],
  },
  extensionsToTreatAsEsm: ['.ts'],
};

Am I missing something in the configuration? Could you also please share your Wallaby Diagnostics report? I'd like to confirm that we're using the same version of node.js.

adcreare commented 8 months ago

Yup your jest.config.js matches mine with that 3333 project. Here is my debug - using node 20.11.1 - however the same thing happens with 21.6.1 and I assume other versions.

{
  editorVersion: 'WebStorm 2023.3.3',
  pluginVersion: '1.0.284',
  editorType: 'IntelliJ',
  osVersion: 'darwin 23.3.0',
  nodeVersion: 'v20.11.1',
  coreVersion: '1.0.1525',
  checksum: 'ZDE0YzdkNzk2YTM3MzM3MWU2YzI3OTA3OWFmZDkyZjYsMTczMTcxNTIwMDAwMCww',
  config: {
    diagnostics: {
      jest: {
        config: {
          configs: [
            {
              automock: false,
              cache: true,
              cacheDirectory: '/private/var/folders/w7/q_97lqz56r55v79plhdf7zx80000gn/T/jest_dx',
              clearMocks: false,
              collectCoverageFrom: [],
              coverageDirectory: '<homeDir>/git/wallaby-3333/coverage',
              coveragePathIgnorePatterns: [ '/node_modules/' ],
              cwd: '<homeDir>/git/wallaby-3333',
              dependencyExtractor: undefined,
              detectLeaks: false,
              detectOpenHandles: false,
              displayName: undefined,
              errorOnDeprecated: false,
              extensionsToTreatAsEsm: [ '.ts' ],
              fakeTimers: { enableGlobally: false },
              filter: undefined,
              forceCoverageMatch: [],
              globalSetup: undefined,
              globalTeardown: undefined,
              globals: {},
              haste: { computeSha1: false, enableSymlinks: false, forceNodeFilesystemAPI: true, throwOnModuleCollision: false },
              id: '6eb0bb5bc4e8d189d6d5492e7c6505ff',
              injectGlobals: true,
              moduleDirectories: [ 'node_modules' ],
              moduleFileExtensions: [
                'js',   'mjs',
                'cjs',  'jsx',
                'ts',   'tsx',
                'json', 'node'
              ],
              moduleNameMapper: [],
              modulePathIgnorePatterns: [],
              modulePaths: undefined,
              openHandlesTimeout: 1000,
              prettierPath: 'prettier',
              resetMocks: false,
              resetModules: false,
              resolver: undefined,
              restoreMocks: false,
              rootDir: '<homeDir>/git/wallaby-3333',
              roots: [ '<homeDir>/git/wallaby-3333' ],
              runner: '<homeDir>/git/wallaby-3333/node_modules/jest-runner/build/index.js',
              runtime: undefined,
              sandboxInjectedGlobals: [],
              setupFiles: [],
              setupFilesAfterEnv: [],
              skipFilter: false,
              skipNodeResolution: undefined,
              slowTestThreshold: 5,
              snapshotFormat: { escapeString: false, printBasicPrototype: false },
              snapshotResolver: undefined,
              snapshotSerializers: [],
              testEnvironment: '<homeDir>/git/wallaby-3333/node_modules/jest-environment-node/build/index.js',
              testEnvironmentOptions: {},
              testLocationInResults: false,
              testMatch: [ '**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[tj]s?(x)' ],
              testPathIgnorePatterns: [ '/node_modules/' ],
              testRegex: [],
              testRunner: '<homeDir>/git/wallaby-3333/node_modules/jest-circus/runner.js',
              transform: [ [ '^.+\\.tsx?$', '<homeDir>/git/wallaby-3333/node_modules/ts-jest/dist/index.js', { isolatedModules: true, diagnostics: false, useESM: true } ] ],
              transformIgnorePatterns: [ '/node_modules/', '\\.pnp\\.[^\\/]+$' ],
              unmockedModulePathPatterns: undefined,
              watchPathIgnorePatterns: []
            }
          ],
          globalConfig: {
            bail: 0,
            changedFilesWithAncestor: false,
            changedSince: undefined,
            ci: false,
            collectCoverage: false,
            collectCoverageFrom: [],
            coverageDirectory: '<homeDir>/git/wallaby-3333/coverage',
            coverageProvider: 'babel',
            coverageReporters: [ 'json', 'text', 'lcov', 'clover' ],
            coverageThreshold: undefined,
            detectLeaks: false,
            detectOpenHandles: false,
            errorOnDeprecated: false,
            expand: false,
            filter: undefined,
            findRelatedTests: false,
            forceExit: false,
            globalSetup: undefined,
            globalTeardown: undefined,
            json: false,
            lastCommit: false,
            listTests: false,
            logHeapUsage: false,
            maxConcurrency: 5,
            maxWorkers: 9,
            noSCM: undefined,
            noStackTrace: false,
            nonFlagArgs: undefined,
            notify: false,
            notifyMode: 'failure-change',
            onlyChanged: false,
            onlyFailures: false,
            openHandlesTimeout: 1000,
            outputFile: undefined,
            passWithNoTests: false,
            projects: [],
            randomize: undefined,
            replname: undefined,
            reporters: undefined,
            rootDir: '<homeDir>/git/wallaby-3333',
            runInBand: undefined,
            runTestsByPath: false,
            seed: 798721966,
            shard: undefined,
            showSeed: undefined,
            silent: undefined,
            skipFilter: false,
            snapshotFormat: { escapeString: false, printBasicPrototype: false },
            testFailureExitCode: 1,
            testNamePattern: undefined,
            testPathPattern: '',
            testResultsProcessor: undefined,
            testSequencer: '<homeDir>/git/wallaby-3333/node_modules/@jest/test-sequencer/build/index.js',
            testTimeout: undefined,
            updateSnapshot: 'new',
            useStderr: false,
            verbose: undefined,
            watch: false,
            watchAll: false,
            watchPlugins: undefined,
            watchman: true,
            workerIdleMemoryLimit: undefined,
            workerThreads: false
          },
          hasDeprecationWarnings: false,
          wallaby: {
            roots: [],
            watchPathIgnorePatterns: [ '/node_modules/', '\\./dist/|\\./build/|\\./coverage/|\\./git/|/\\..+/', '/private/var/folders/w7/q_97lqz56r55v79plhdf7zx80000gn/T/jest_dx', '\\./coverage' ],
            testPathIgnorePatterns: [ '/node_modules/', '\\./dist/|\\./build/|\\./coverage/|\\./git/|/\\..+/', '/private/var/folders/w7/q_97lqz56r55v79plhdf7zx80000gn/T/jest_dx', '\\./coverage' ],
            testMatch: [ '**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[tj]s?(x)' ],
            testRegex: []
          }
        }
      }
    },
    testFramework: { version: 'jest@24.8.0', configurator: 'jest@24.8.0', reporter: 'jest@24.8.0', starter: 'jest@24.8.0', autoDetected: true },
    filesWithCoverageCalculated: [],
    filesWithNoCoverageCalculated: [],
    globalSetup: false,
    dot: true,
    files: [
      { pattern: '/node_modules/', regexp: /\/node_modules\//, ignore: true, trigger: true, load: true, file: true, test: true },
      {
        pattern: '\\./dist/|\\./build/|\\./coverage/|\\./git/|/\\..+/',
        regexp: /\.\/dist\/|\.\/build\/|\.\/coverage\/|\.\/git\/|\/\..+\//,
        ignore: true,
        trigger: true,
        load: true,
        file: true,
        test: true
      },
      {
        pattern: '/private/var/folders/w7/q_97lqz56r55v79plhdf7zx80000gn/T/jest_dx',
        regexp: /\/private\/var\/folders\/w7\/q_97lqz56r55v79plhdf7zx80000gn\/T\/jest_dx/,
        ignore: true,
        trigger: true,
        load: true,
        file: true,
        test: true
      },
      { pattern: '\\./coverage', regexp: /\.\/coverage/, ignore: true, trigger: true, load: true, file: true, test: true },
      { pattern: '**/**', ignore: false, trigger: true, load: true, order: 1 },
      { pattern: '**/__tests__/**/*.[jt]s?(x)', ignore: true, trigger: true, load: true, file: true },
      { pattern: '**/?(*.)+(spec|test).[tj]s?(x)', ignore: true, trigger: true, load: true, file: true }
    ],
    captureConsoleLog: true,
    tests: [
      { pattern: '/node_modules/', regexp: /\/node_modules\//, ignore: true, trigger: true, load: true, test: true, file: false },
      {
        pattern: '\\./dist/|\\./build/|\\./coverage/|\\./git/|/\\..+/',
        regexp: /\.\/dist\/|\.\/build\/|\.\/coverage\/|\.\/git\/|\/\..+\//,
        ignore: true,
        trigger: true,
        load: true,
        test: true,
        file: false
      },
      {
        pattern: '/private/var/folders/w7/q_97lqz56r55v79plhdf7zx80000gn/T/jest_dx',
        regexp: /\/private\/var\/folders\/w7\/q_97lqz56r55v79plhdf7zx80000gn\/T\/jest_dx/,
        ignore: true,
        trigger: true,
        load: true,
        test: true,
        file: false
      },
      { pattern: '\\./coverage', regexp: /\.\/coverage/, ignore: true, trigger: true, load: true, test: true, file: false },
      { pattern: '**/__tests__/**/*.[jt]s?(x)', ignore: false, trigger: true, load: true, test: true, order: 2 },
      { pattern: '**/?(*.)+(spec|test).[tj]s?(x)', ignore: false, trigger: true, load: true, test: true, order: 3 }
    ],
    runAllTestsInAffectedTestFile: false,
    updateNoMoreThanOneSnapshotPerTestFileRun: false,
    compilers: {},
    logLimits: { inline: { depth: 5, elements: 5000 }, values: { default: { stringLength: 200 }, autoExpand: { elements: 5000, stringLength: 8192, depth: 10 } } },
    preprocessors: {},
    maxConsoleMessagesPerTest: 100,
    autoConsoleLog: true,
    delays: { run: 0, edit: 100, update: 0 },
    workers: { initial: 0, regular: 0, recycle: false },
    teardown: undefined,
    hints: {
      ignoreCoverage: '__REGEXP /ignore coverage|istanbul ignore|c8 ignore/',
      ignoreCoverageForFile: '__REGEXP /ignore file coverage/',
      commentAutoLog: '?',
      testFileSelection: { include: '__REGEXP /file\\.only/', exclude: '__REGEXP /file\\.skip/' }
    },
    automaticTestFileSelection: true,
    runSelectedTestsOnly: false,
    mapConsoleMessagesStackTrace: false,
    extensions: {},
    env: { type: 'node', params: {}, runner: '<homeDir>/.nvm/versions/node/v20.11.1/bin/node', viewportSize: { width: 800, height: 600 }, options: { width: 800, height: 600 }, bundle: true },
    reportUnhandledPromises: true,
    slowTestThreshold: 75,
    lowCoverageThreshold: 80,
    runAllTestsWhenNoAffectedTests: false,
    configCode: 'auto.detect#-278026206'
  },
  packageJSON: {
    dependencies: {
      '@checkdigit/hash': '^2.0.2',
      '@checkdigit/time': '^2.0.0',
      '@checkdigit/typescript-config': '^6.0.0',
      '@jest/globals': '^29.7.0',
      'aws-sdk': '^2.1559.0',
      moment: '^2.30.1',
      rimraf: '^5.0.5',
      'ts-node': '^10.9.2'
    },
    devDependencies: { '@checkdigit/jest-config': '^6.0.0', '@types/jest': '^29.5.12', jest: '^29.7.0', 'ts-jest': '^29.1.2', typescript: '^5.3.3' }
  },
  fs: { numberOfFiles: 7 },
  debug: [
    '2024-02-16T02:05:42.358Z project waiting for initial run signal\n',
    '2024-02-16T02:05:42.363Z config Attempting automatic configuration for angular\n',
    '2024-02-16T02:05:42.363Z angular/cli config Angular CLI not found.\n',
    '2024-02-16T02:05:42.363Z config Finished attempting automatic configuration for angular (0ms)\n',
    '2024-02-16T02:05:42.363Z config Attempting automatic configuration for jest\n',
    '2024-02-16T02:05:42.397Z jest/config Detected Jest.\n',
    '2024-02-16T02:05:42.397Z jest/config Configured Jest.\n',
    '2024-02-16T02:05:42.397Z config Finished attempting automatic configuration for jest (34ms)\n',
    '2024-02-16T02:05:42.398Z project Wallaby Node version: v20.11.1\n',
    '2024-02-16T02:05:42.398Z project Wallaby config: <homeDir>/git/wallaby-3333/auto.detect\n',
    '2024-02-16T02:05:42.421Z fs File system starting\n',
    '2024-02-16T02:05:42.436Z fs File system scan completed\n',
    '2024-02-16T02:05:42.439Z project File cache: <homeDir>/Library/Caches/JetBrains/WebStorm2023.3/wallaby/projects/4f1ceabcaa04e990\n',
    '2024-02-16T02:05:42.442Z uiService Listening port 51236\n',
    '2024-02-16T02:05:42.443Z project package.json file change detected, invalidating local cache\n',
    '2024-02-16T02:05:42.446Z workers Parallelism for initial run: 8, for regular run: 4\n',
    '2024-02-16T02:05:42.446Z workers Starting run worker instance #0\n',
    '2024-02-16T02:05:42.446Z workers Starting run worker instance #1\n',
    '2024-02-16T02:05:42.446Z workers Starting run worker instance #2\n',
    '2024-02-16T02:05:42.446Z workers Starting run worker instance #3\n',
    '2024-02-16T02:05:42.446Z workers Starting run worker instance #4\n',
    '2024-02-16T02:05:42.446Z workers Starting run worker instance #5\n',
    '2024-02-16T02:05:42.446Z workers Starting run worker instance #6\n',
    '2024-02-16T02:05:42.446Z workers Starting run worker instance #7\n',
    '2024-02-16T02:05:42.447Z workers Web server is listening at 55083\n',
    '2024-02-16T02:05:42.447Z project File cache requires some updates, waiting required files from IDE\n',
    '2024-02-16T02:05:42.464Z project Stopping process pool\n',
    '2024-02-16T02:05:42.467Z project Test run started; run priority: 3\n',
    '2024-02-16T02:05:42.468Z project Running all tests\n',
    '2024-02-16T02:05:42.468Z workers Starting test run, priority: 3\n',
    '2024-02-16T02:05:42.468Z nodeRunner Starting sandbox [worker #0, session #3bmyr]\n',
    '2024-02-16T02:05:42.468Z nodeRunner Preparing sandbox [worker #0, session #3bmyr]\n',
    '2024-02-16T02:05:42.543Z workers Started run worker instance (delayed) #0\n',
    '2024-02-16T02:05:42.543Z nodeRunner Prepared sandbox [worker #0, session #3bmyr]\n',
    '2024-02-16T02:05:42.543Z workers [worker #0, session #3bmyr] Running tests in sandbox\n',
    '2024-02-16T02:05:42.544Z workers Started run worker instance (delayed) #2\n',
    '2024-02-16T02:05:42.545Z workers Started run worker instance (delayed) #1\n',
    '2024-02-16T02:05:42.546Z workers Started run worker instance (delayed) #4\n',
    '2024-02-16T02:05:42.549Z workers Started run worker instance (delayed) #6\n',
    '2024-02-16T02:05:42.550Z workers Started run worker instance (delayed) #3\n',
    '2024-02-16T02:05:42.552Z workers Started run worker instance (delayed) #7\n',
    '2024-02-16T02:05:42.557Z workers Started run worker instance (delayed) #5\n',
    "2024-02-16T02:05:42.676Z workers 'Scheduling Jest Test Run (3bmyr): 2024-02-16T02:05:42.673Z'\n",
    '2024-02-16T02:05:42.959Z workers Sandbox (active) [3bmyr] error: Failed to instrument src/a.sample.spec.ts\n' +
      "  1 | import { describe, it } from '@jest/globals';\n" +
      "> 2 | import schema from './schema.json' with { type: 'json' };\n" +
      '    |                                    ^ SyntaxError: Unexpected token (2:35)\n' +
      "  3 | describe('test', () => {\n" +
      "  4 |     it('test', () => {\n" +
      '  5 |         console.log(schema);\n' +
      '    at ScriptTransformer.transformSourceAsync (./node_modules/@jest/transform/build/ScriptTransformer.js:599:19)\n' +
      '    at ScriptTransformer._transformAndBuildScriptAsync (./node_modules/@jest/transform/build/ScriptTransformer.js:639:35)\n' +
      '    at ScriptTransformer.transformAsync (./node_modules/@jest/transform/build/ScriptTransformer.js:703:14)\n' +
      '    at Runtime.transformFileAsync (./node_modules/jest-runtime/build/index.js:1484:29)\n' +
      '    at Runtime.loadEsmModule (./node_modules/jest-runtime/build/index.js:493:31)\n' +
      '    at Runtime.unstable_importModule (./node_modules/jest-runtime/build/index.js:721:20)\n' +
      '    at jestAdapter (./node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:75:5)\n' +
      '    at runTestInternal (./node_modules/jest-runner/build/runTest.js:367:16)\n' +
      '    at runTest (./node_modules/jest-runner/build/runTest.js:444:34)\n',
    '2024-02-16T02:05:42.959Z workers [3bmyr] Run 0 test(s), skipped 0 test(s)\n',
    "2024-02-16T02:05:42.960Z workers 'Jest Test Run Complete (3bmyr): 2024-02-16T02:05:42.960Z'\n",
    '2024-02-16T02:05:42.960Z workers [3bmyr] Sandbox is responsive, closing it\n',
    '2024-02-16T02:05:42.961Z workers Failed to map the stack to user code, entry message: Failed to instrument src/a.sample.spec.ts\n' +
      "  1 | import { describe, it } from '@jest/globals';\n" +
      "> 2 | import schema from './schema.json' with { type: 'json' };\n" +
      '    |                                    ^ SyntaxError: Unexpected token (2:35)\n' +
      "  3 | describe('test', () => {\n" +
      "  4 |     it('test', () => {\n" +
      '  5 |         console.log(schema);, stack: Error: Failed to instrument src/a.sample.spec.ts\n' +
      "  1 | import { describe, it } from '@jest/globals';\n" +
      "> 2 | import schema from './schema.json' with { type: 'json' };\n" +
      '    |                                    ^ SyntaxError: Unexpected token (2:35)\n' +
      "  3 | describe('test', () => {\n" +
      "  4 |     it('test', () => {\n" +
      '  5 |         console.log(schema);\n' +
      '    at Object.formatInstrumentationError (<homeDir>/Library/Caches/JetBrains/WebStorm2023.3/wallaby/wallaby/server.js:507:99682)\n' +
      '    at i (<homeDir>/Library/Caches/JetBrains/WebStorm2023.3/wallaby/wallaby/runners/node/jest@24.8.0/initializer.js:36:15236)\n' +
      '    at l.processAsync (<homeDir>/Library/Caches/JetBrains/WebStorm2023.3/wallaby/wallaby/runners/node/jest@24.8.0/initializer.js:36:17385)\n' +
      '    at ScriptTransformer.transformSourceAsync (<homeDir>/git/wallaby-3333/node_modules/@jest/transform/build/ScriptTransformer.js:599:19)\n' +
      '    at ScriptTransformer._transformAndBuildScriptAsync (<homeDir>/git/wallaby-3333/node_modules/@jest/transform/build/ScriptTra\n',
    '2024-02-16T02:05:42.961Z project Test run finished\n',
    '2024-02-16T02:05:42.961Z project Processed console.log entries\n',
    '2024-02-16T02:05:42.961Z project Processed loading sequences\n',
    '2024-02-16T02:05:42.961Z project Processed executed tests\n',
    '2024-02-16T02:05:42.961Z project Processed code coverage\n',
    '2024-02-16T02:05:42.964Z project Test run result processed and sent to IDE\n'
  ]
}
smcenlly commented 8 months ago

We're a little unsure of why we can't reproduce your exact problem but have isolated the cause in a project that uses vanilla JavaScript.

Wallaby currently does not support the use of import attributes. We will look at adding support soon.

adcreare commented 8 months ago

I'm not sure if this is relevant. But I can only seem to produce the issue using jetbrains webstorm, when I use wallabyjs with vscode I don't get any errors and the tests pass.

ArtemGovorov commented 8 months ago

@adcreare We have tried reproducing in WebStorm 2023.3.3, but still unable to. Having said that, we have now added native support of of import attributes use in Wallaby core. Please try updating to the latest core v1.0.528 and check if the sample project and your real project are working now in WebStorm?

ramaghanta commented 8 months ago

the latest Wallaby core v1.0.1528 fixed this problem in both sample project as well as my real project. Thank you for taking care of it.