wallabyjs / public

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

Unable to make Wallaby.js work with Angular CLI + Jest #3144

Closed node-ex closed 1 year ago

node-ex commented 1 year ago

Hello,

I have a small project that is based on Angular CLI + Jest setup (via Angular Jest Builder). ng test works, but Wallaby.js does not, even though, according to documentation, it should work with Automatic configuration.

Here is the only test in the project:

import { describe, it, expect } from '@jest/globals';
import { TestBed } from '@angular/core/testing';
import { AppComponent } from './app.component';

describe('AppComponent', () => {
  it('should be true', () => {
    expect(true).toBe(true);
  });

  it('the title is correctly set', async () => {
    const fixture = TestBed.createComponent(AppComponent);
    const app = fixture.debugElement.componentInstance;

    await new Promise((resolve) => setTimeout(resolve, 0));
    expect(app.title).toEqual('angular-tic-tac-toe');
  });
});

It fails on the first import with an error SyntaxError: Cannot use import statement outside a module. It looks like *.spec.ts files are not transpiled into the JS form that can be read by Jest.

There are 2 configs with custom names that are used when running Jest tests: jest.config.angular.ts and tsconfig.spec.ts.

Could you, please, help me make this setup work with Wallaby.js?

Wallaby diagnostics report

Wallaby diagnostics report ``` { editorVersion: '1.74.2', pluginVersion: '1.0.348', editorType: 'VSCode', osVersion: 'linux 5.4.0-135-generic', nodeVersion: 'v16.17.0', coreVersion: '1.0.1365', checksum: 'NjU0ZjZhMmY2NWM4ZWExMGIyZDYyMmIxYWQxNDVmMDgsMTcwMDc4NDAwMDAwMCww', config: { diagnostics: { angular: { workspace: { '$schema': './node_modules/@angular/cli/lib/config/schema.json', version: 1, newProjectRoot: 'projects', projects: { 'angular-tic-tac-toe': { projectType: 'application', schematics: { '@schematics/angular:component': { style: 'scss' } }, root: '', sourceRoot: 'src', prefix: 'app', architect: { build: { builder: '@angular-builders/custom-webpack:browser', options: { customWebpackConfig: { path: './custom-webpack.config.ts' }, main: 'src/main.ts', index: 'src/index.html', tsConfig: 'tsconfig.app.json', outputPath: 'dist/angular-tic-tac-toe', polyfills: [ 'zone.js' ], assets: [ 'src/favicon.ico', 'src/assets', 'src/manifest.webmanifest' ], inlineStyleLanguage: 'scss', styles: [ 'node_modules/primeicons/primeicons.css', 'node_modules/primeng/resources/themes/lara-dark-blue/theme.css', 'node_modules/primeng/resources/primeng.min.css', 'src/styles.scss' ], scripts: [], serviceWorker: true, ngswConfigPath: 'ngsw-config.json' }, configurations: { production: { fileReplacements: [ { replace: 'src/environments/environment.ts', with: 'src/environments/environment.production.ts' } ], budgets: [ { type: 'initial', maximumWarning: '500kb', maximumError: '1mb' }, { type: 'anyComponentStyle', maximumWarning: '2kb', maximumError: '4kb' } ], outputHashing: 'all' }, development: { fileReplacements: [ { replace: 'src/environments/environment.ts', with: 'src/environments/environment.development.ts' } ], buildOptimizer: false, optimization: false, vendorChunk: true, extractLicenses: false, sourceMap: true, namedChunks: true } }, defaultConfiguration: 'production' }, serve: { builder: '@angular-builders/custom-webpack:dev-server', options: { browserTarget: 'angular-tic-tac-toe:build' }, configurations: { production: { browserTarget: 'angular-tic-tac-toe:build:production' }, development: { browserTarget: 'angular-tic-tac-toe:build:development' } }, defaultConfiguration: 'development' }, 'extract-i18n': { builder: '@angular-builders/custom-webpack:extract-i18n', options: { browserTarget: 'angular-tic-tac-toe:build' } }, lint: { builder: '@angular-eslint/builder:lint', options: { lintFilePatterns: [ 'src/**/*.ts', 'src/**/*.html' ] } }, deploy: { builder: '@angular/fire:deploy', options: { prerender: false, ssr: false, browserTarget: 'angular-tic-tac-toe:build:production', firebaseProject: 'angular-tic-tac-toe-eb2e5', firebaseHostingSite: 'angular-tic-tac-toe-eb2e5' } }, test: { builder: '@angular-builders/jest:run', options: { configPath: 'jest.config.angular.js', tsConfig: 'tsconfig.spec.json', assets: [ 'src/favicon.ico', 'src/assets' ], styles: [ 'src/styles.scss' ], scripts: [] } } } } }, cli: { schematicCollections: [ '@angular-eslint/schematics' ] } } }, jest: { config: { configs: [ { automock: false, cache: true, cacheDirectory: '/tmp/jest_rs', clearMocks: false, coveragePathIgnorePatterns: [ '/node_modules/' ], cwd: '/angular-project', dependencyExtractor: undefined, detectLeaks: false, detectOpenHandles: false, displayName: undefined, errorOnDeprecated: false, extensionsToTreatAsEsm: [], fakeTimers: { enableGlobally: false }, filter: undefined, forceCoverageMatch: [], globalSetup: undefined, globalTeardown: undefined, globals: {}, haste: { computeSha1: false, enableSymlinks: false, forceNodeFilesystemAPI: true, throwOnModuleCollision: false }, id: 'd7a3778b899cab780888cfa454968787', injectGlobals: true, moduleDirectories: [ 'node_modules' ], moduleFileExtensions: [ 'js', 'mjs', 'cjs', 'jsx', 'ts', 'tsx', 'json', 'node' ], moduleNameMapper: [], modulePathIgnorePatterns: [], modulePaths: undefined, prettierPath: 'prettier', resetMocks: false, resetModules: false, resolver: undefined, restoreMocks: false, rootDir: '/angular-project', roots: [ '/angular-project' ], runner: '/angular-project/node_modules/jest-runner/build/index.js', runtime: undefined, sandboxInjectedGlobals: [], setupFiles: [], setupFilesAfterEnv: [], skipFilter: false, skipNodeResolution: undefined, slowTestThreshold: 5, snapshotFormat: undefined, snapshotResolver: undefined, snapshotSerializers: [], testEnvironment: '/angular-project/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: '/angular-project/node_modules/jest-circus/runner.js', transform: [ [ '\\.[jt]sx?$', '/angular-project/node_modules/babel-jest/build/index.js', {} ] ], transformIgnorePatterns: [ '/node_modules/', '\\.pnp\\.[^\\/]+$' ], unmockedModulePathPatterns: undefined, watchPathIgnorePatterns: [] } ], globalConfig: { bail: 0, changedFilesWithAncestor: false, changedSince: undefined, ci: false, collectCoverage: false, collectCoverageFrom: [], collectCoverageOnlyFrom: undefined, coverageDirectory: '/angular-project/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: 7, noSCM: undefined, noStackTrace: false, nonFlagArgs: undefined, notify: false, notifyMode: 'failure-change', onlyChanged: false, onlyFailures: false, outputFile: undefined, passWithNoTests: false, projects: [], replname: undefined, reporters: undefined, rootDir: '/angular-project', runTestsByPath: false, shard: undefined, silent: undefined, skipFilter: false, snapshotFormat: undefined, testFailureExitCode: 1, testNamePattern: undefined, testPathPattern: '', testResultsProcessor: undefined, testSequencer: '/angular-project/node_modules/@jest/test-sequencer/build/index.js', testTimeout: undefined, updateSnapshot: 'new', useStderr: false, verbose: undefined, watch: false, watchAll: false, watchPlugins: undefined, watchman: true }, hasDeprecationWarnings: false, wallaby: { roots: [], watchPathIgnorePatterns: [ '/node_modules/', '\\./dist/|\\./build/|\\./coverage/|\\./git/|/\\..+/', '/tmp/jest_rs', '\\./coverage' ], testPathIgnorePatterns: [ '/node_modules/', '\\./dist/|\\./build/|\\./coverage/|\\./git/|/\\..+/', '/tmp/jest_rs', '\\./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, customJestConfig: { configs: [ { automock: false, cache: true, cacheDirectory: '/tmp/jest_rs', clearMocks: false, coveragePathIgnorePatterns: [ '/node_modules/' ], cwd: '/angular-project', dependencyExtractor: undefined, detectLeaks: false, detectOpenHandles: false, displayName: undefined, errorOnDeprecated: false, extensionsToTreatAsEsm: [], fakeTimers: { enableGlobally: false }, filter: undefined, forceCoverageMatch: [], globalSetup: undefined, globalTeardown: undefined, globals: {}, haste: { computeSha1: false, enableSymlinks: false, forceNodeFilesystemAPI: true, throwOnModuleCollision: false }, id: 'd7a3778b899cab780888cfa454968787', injectGlobals: true, moduleDirectories: [ 'node_modules' ], moduleFileExtensions: [ 'js', 'mjs', 'cjs', 'jsx', 'ts', 'tsx', 'json', 'node' ], moduleNameMapper: [], modulePathIgnorePatterns: [], modulePaths: undefined, prettierPath: 'prettier', resetMocks: false, resetModules: false, resolver: undefined, restoreMocks: false, rootDir: '/angular-project', roots: [ '/angular-project' ], runner: '/angular-project/node_modules/jest-runner/build/index.js', runtime: undefined, sandboxInjectedGlobals: [], setupFiles: [], setupFilesAfterEnv: [], skipFilter: false, skipNodeResolution: undefined, slowTestThreshold: 5, snapshotFormat: undefined, snapshotResolver: undefined, snapshotSerializers: [], testEnvironment: '/angular-project/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: '/angular-project/node_modules/jest-circus/runner.js', transform: [ [ '\\.[jt]sx?$', '/angular-project/node_modules/babel-jest/build/index.js', {} ] ], transformIgnorePatterns: [ '/node_modules/', '\\.pnp\\.[^\\/]+$' ], unmockedModulePathPatterns: undefined, watchPathIgnorePatterns: [] } ], globalConfig: { bail: 0, changedFilesWithAncestor: false, changedSince: undefined, ci: false, collectCoverage: false, collectCoverageFrom: [], collectCoverageOnlyFrom: undefined, coverageDirectory: '/angular-project/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: 7, noSCM: undefined, noStackTrace: false, nonFlagArgs: undefined, notify: false, notifyMode: 'failure-change', onlyChanged: false, onlyFailures: false, outputFile: undefined, passWithNoTests: false, projects: [], replname: undefined, reporters: undefined, rootDir: '/angular-project', runTestsByPath: false, shard: undefined, silent: undefined, skipFilter: false, snapshotFormat: undefined, testFailureExitCode: 1, testNamePattern: undefined, testPathPattern: '', testResultsProcessor: undefined, testSequencer: '/angular-project/node_modules/@jest/test-sequencer/build/index.js', testTimeout: undefined, updateSnapshot: 'new', useStderr: false, verbose: undefined, watch: false, watchAll: false, watchPlugins: undefined, watchman: true }, hasDeprecationWarnings: false, wallaby: { roots: [], watchPathIgnorePatterns: [ '/node_modules/', '\\./dist/|\\./build/|\\./coverage/|\\./git/|/\\..+/', '/tmp/jest_rs', '\\./coverage' ], testPathIgnorePatterns: [ '/node_modules/', '\\./dist/|\\./build/|\\./coverage/|\\./git/|/\\..+/', '/tmp/jest_rs', '\\./coverage' ], testMatch: [ '**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[tj]s?(x)' ], testRegex: [] } }, 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: '/tmp/jest_rs', regexp: /\/tmp\/jest_rs/, 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 } ], 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: '/tmp/jest_rs', regexp: /\/tmp\/jest_rs/, 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/', 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: '/.asdf/installs/nodejs/16.17.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#1359811502' }, packageJSON: { dependencies: { '@angular/animations': '^15.0.0', '@angular/common': '^15.0.0', '@angular/compiler': '^15.0.0', '@angular/core': '^15.0.0', '@angular/fire': '^7.5.0', '@angular/forms': '^15.0.0', '@angular/platform-browser': '^15.0.0', '@angular/platform-browser-dynamic': '^15.0.0', '@angular/router': '^15.0.0', '@angular/service-worker': '^15.0.0', memoizee: '^0.4.15', primeicons: '^6.0.1', primeng: '^15.0.1', rxjs: '~7.5.0', tslib: '^2.3.0', 'zone.js': '~0.12.0' }, devDependencies: { '@angular-builders/custom-webpack': '^15.0.0', '@angular-builders/jest': '15.0.0', '@angular-devkit/build-angular': '^15.0.4', '@angular-eslint/builder': '15.1.0', '@angular-eslint/eslint-plugin': '15.1.0', '@angular-eslint/eslint-plugin-template': '15.1.0', '@angular-eslint/schematics': '15.1.0', '@angular-eslint/template-parser': '15.1.0', '@angular/cli': '~15.0.4', '@angular/compiler-cli': '^15.0.0', '@faker-js/faker': '7.6.0', '@fast-check/jest': '1.6.0', '@istanbuljs/nyc-config-typescript': '1.0.2', '@istanbuljs/schema': '0.1.3', '@stryker-mutator/core': '6.3.1', '@stryker-mutator/typescript-checker': '6.3.1', '@types/jest': '29.2.5', '@types/memoizee': '^0.4.8', '@typescript-eslint/eslint-plugin': '5.44.0', '@typescript-eslint/parser': '5.44.0', dotenv: '^16.0.3', eslint: '^8.28.0', 'eslint-config-prettier': '^8.6.0', 'eslint-plugin-prettier': '^4.2.1', jest: '28.1.3', prettier: '^2.8.2', 'source-map-explorer': '^2.5.3', typescript: '~4.8.2', 'webpack-bundle-analyzer': '^4.7.0' } }, fs: { numberOfFiles: 88 }, debug: [ '2023-01-10T21:52:44.302Z config Attempting automatic configuration for angular\n', '2023-01-10T21:52:44.306Z angular/cli config Detected Angular CLI.\n', '2023-01-10T21:52:44.308Z angular/cli config Angular currentDirPath: "/angular-project", workspaceDirPath: "/angular-project"\n', '2023-01-10T21:52:45.100Z jest/config Detected Jest.\n', '2023-01-10T21:52:45.101Z jest/config Configured Jest.\n', '2023-01-10T21:52:45.101Z config Finished attempting automatic configuration for angular (799ms)\n', '2023-01-10T21:52:45.103Z project Wallaby Node version: v16.17.0\n', '2023-01-10T21:52:45.103Z project Wallaby config: /angular-project/auto.detect\n', '2023-01-10T21:52:45.117Z fs File system starting\n', '2023-01-10T21:52:45.227Z fs File system scan completed\n', '2023-01-10T21:52:45.236Z project File cache: /.vscode/extensions/wallabyjs.wallaby-vscode-1.0.348/projects/47a1dabceaf306a6\n', '2023-01-10T21:52:45.318Z uiService Listening port 51235\n', '2023-01-10T21:52:45.327Z project package.json file change detected, invalidating local cache\n', '2023-01-10T21:52:45.335Z workers Parallelism for initial run: 6, for regular run: 3\n', '2023-01-10T21:52:45.336Z workers Starting run worker instance #0\n', '2023-01-10T21:52:45.336Z workers Starting run worker instance #1\n', '2023-01-10T21:52:45.336Z workers Starting run worker instance #2\n', '2023-01-10T21:52:45.336Z workers Starting run worker instance #3\n', '2023-01-10T21:52:45.336Z workers Starting run worker instance #4\n', '2023-01-10T21:52:45.336Z workers Starting run worker instance #5\n', '2023-01-10T21:52:45.336Z workers Web server is listening at 44937\n', '2023-01-10T21:52:45.337Z project File cache requires some updates, waiting required files from IDE\n', '2023-01-10T21:52:45.419Z project Stopping process pool\n', '2023-01-10T21:52:45.422Z project Test run started; run priority: 3\n', '2023-01-10T21:52:45.424Z project Running all tests\n', '2023-01-10T21:52:45.429Z workers Starting test run, priority: 3\n', '2023-01-10T21:52:45.429Z nodeRunner Starting sandbox [worker #0, session #gik4d]\n', '2023-01-10T21:52:45.429Z nodeRunner Preparing sandbox [worker #0, session #gik4d]\n', '2023-01-10T21:52:45.558Z workers Started run worker instance (delayed) #0\n', '2023-01-10T21:52:45.559Z nodeRunner Prepared sandbox [worker #0, session #gik4d]\n', '2023-01-10T21:52:45.559Z workers [worker #0, session #gik4d] Running tests in sandbox\n', '2023-01-10T21:52:45.579Z workers Started run worker instance (delayed) #1\n', '2023-01-10T21:52:45.603Z workers Started run worker instance (delayed) #2\n', '2023-01-10T21:52:45.620Z workers Started run worker instance (delayed) #3\n', '2023-01-10T21:52:45.629Z workers Started run worker instance (delayed) #4\n', '2023-01-10T21:52:45.640Z workers Started run worker instance (delayed) #5\n', '2023-01-10T21:52:46.973Z workers Scheduling Jest Test Run (gik4d): 2023-01-10T21:52:46.081Z\n', '2023-01-10T21:52:46.986Z workers Sandbox (active) [gik4d] error: Jest encountered an unexpected token\n' + '\n' + 'Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.\n' + '\n' + 'Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.\n' + '\n' + 'By default "node_modules" folder is ignored by transformers.\n' + '\n' + "Here's what you can do:\n" + ' • If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/ecmascript-modules for how to enable it.\n' + ' • If you are trying to use TypeScript, see https://jestjs.io/docs/getting-started#using-typescript\n' + ' • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.\n' + ' • If you need a custom transformation specify a "transform" option in your config.\n' + ' • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.\n' + '\n' + "You'll find more details and examples of these config options in the docs:\n" + 'https://jestjs.io/docs/configuration\n' + 'For information about custom transformations, see:\n' + 'https://jestjs.io/docs/code-transformation\n' + '\n' + 'Details:\n' + '\n' + './src/app/app.component.spec.ts:2\n' + 'import {\n' + '^^^^^^\n' + '\n' + 'SyntaxError: Cannot use import statement outside a module\n' + ' at new Script (node:vm:100:7)\n' + ' at Runtime.createScriptFromCode (./node_modules/jest-runtime/build/index.js:1796:14)\n' + ' at Runtime._execModule (./node_modules/jest-runtime/build/index.js:1664:25)\n' + ' at Runtime._loadModule (./node_modules/jest-runtime/build/index.js:1223:12)\n' + ' at Runtime.requireModule (./node_modules/jest-runtime/build/index.js:1047:12)\n' + ' at jestAdapter (./node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:89:13)\n' + ' at runTestInternal (./node_modules/jest-runner/build/runTest.js:411:16)\n' + ' at runTest (./node_modules/jest-runner/build/runTest.js:499:34)\n', '2023-01-10T21:52:46.989Z workers [gik4d] Run 0 test(s), skipped 0 test(s)\n', '2023-01-10T21:52:46.990Z workers Jest Test Run Complete (gik4d): 2023-01-10T21:52:46.966Z\n', '2023-01-10T21:52:46.992Z workers [gik4d] Sandbox is responsive, closing it\n', '2023-01-10T21:52:46.995Z project Test run finished\n', '2023-01-10T21:52:46.996Z project Processed console.log entries\n', '2023-01-10T21:52:46.996Z project Processed loading sequences\n', '2023-01-10T21:52:46.996Z project Processed executed tests\n', '2023-01-10T21:52:46.997Z project Processed code coverage\n', '2023-01-10T21:52:47.017Z project Test run result processed and sent to IDE\n' ] } ```
ArtemGovorov commented 1 year ago

There are 2 configs with custom names that are used when running Jest tests: jest.config.angular.ts and tsconfig.spec.ts.

Hello, since you are using a custom jest config file name, the docs section that you have referenced points to the article on how to override Wallaby auto-config to specify custom Jest config path:

module.exports = () => {
  return {
    testFramework: {
      // the jest configuration file path
      // (relative to project root)
      configFile: './jest.config.angular.ts'
    }
  }
};

Please try the solution and let us know if it's working for you.

node-ex commented 1 year ago

@ArtemGovorov Thank you for a suggestion, tried it out by creating wallaby.js file and pointing Wallaby.js extension to it (VSCode -> Wallaby.js: Select Configuration), but it did not change the error message.

To be clear, I did see the mentioned section in the documentation and tried other configuration settings as well, but after multiple unsuccessful attempts decided to start from scratch, without it. Here is the config that I used before - I experimented with it by iteratively commenting/uncommenting some parts and seeing whether it will help, but without success:

`wallaby.js` contents ``` module.exports = function () { return { // env: { // type: 'node', // }, testFramework: { configFile: './jest.config.angular.js', }, // testFramework: 'jest', // setup: function (wallaby) { // const jestConfig = require('./jest.config.angular'); // // @ts-ignore // delete jestConfig.transform; // wallaby.testFramework.configure(jestConfig); // }, // files: [ // // './src/app/**/*.ts', // 'src/**/*.+(ts|html|json|snap|css|less|sass|scss|jpg|jpeg|gif|png|svg)', // 'tsconfig.json', // 'jest.config.angular.js', // 'tsconfig.spec.json', // '!./src/app/**/*.{spec,test}.ts', // '!**/node_modules/**/*', // ], // tests: ['./src/app/**/*.{spec,test}.ts', '!**/node_modules/**/*'], // hints: { // ignoreCoverageForFile: /Wallaby ignore file coverage/, // ignoreCoverage: /Wallaby ignore coverage/, // }, // trace: true, }; }; ```
ArtemGovorov commented 1 year ago

testFramework: { configFile: './jest.config.angular.js', },

This should be enough, however it's referencing a .js file, while you have originally mentioned that your Jest config is a .t file jest.config.angular.ts. Can you please check the discrepancy and try changing the extension in your config if the config file is .ts file.

Can you please also share

node-ex commented 1 year ago

Sorry for the confusion regarding the filenames, I have provided incorrect extensions, here are the correct ones:

`jest.config.angular.js` contents ``` const { pathsToModuleNameMapper } = require('ts-jest'); // Used JSON5 instead of JSON.parse to parse tsconfig.json // in order to support comments in tsconfig.json const JSON5 = require('json5'); const fs = require('fs'); const TSCONFIG_PATH = './tsconfig.json'; const { compilerOptions } = parseJsoncTsconfig(TSCONFIG_PATH); module.exports = { preset: 'jest-preset-angular', globalSetup: 'jest-preset-angular/global-setup', setupFilesAfterEnv: ['/setup-jest.ts'], testEnvironment: 'jsdom', verbose: true, testMatch: ['**/src/app/**/*.spec.ts'], testPathIgnorePatterns: [ '/(?:production_)?node_modules/', '.d.ts$', 'fixtures', 'helpers', '__mocks__', ], modulePaths: [compilerOptions.baseUrl], moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { prefix: '/', }), coverageDirectory: '/reports/jest/unit', coverageReporters: ['html', 'text'], transform: { '^.+\\.(mjs|js|jsx|ts|tsx|html|svg)$': 'jest-preset-angular', }, globals: { 'ts-jest': { // No type checking, but faster tests isolatedModules: true, }, }, }; function parseJsoncTsconfig(path) { const buffer = fs.readFileSync(path); const fileContent = buffer.toString(); const tsconfig = JSON5.parse(fileContent); return tsconfig; } ```

New Wallaby diagnostics report, based on the setup with wallaby.js config file:

New Wallaby diagnostics report ``` { editorVersion: '1.74.2', pluginVersion: '1.0.348', editorType: 'VSCode', osVersion: 'linux 5.4.0-135-generic', nodeVersion: 'v16.17.0', coreVersion: '1.0.1366', checksum: 'NjU0ZjZhMmY2NWM4ZWExMGIyZDYyMmIxYWQxNDVmMDgsMTcwMDc4NDAwMDAwMCww', config: { testFramework: { version: 'jest@24.8.0', configurator: 'jest@24.8.0', reporter: 'jest@24.8.0', starter: 'jest@24.8.0', configFile: './jest.config.angular.js', autoDetected: true }, diagnostics: { angular: { workspace: { '$schema': './node_modules/@angular/cli/lib/config/schema.json', version: 1, newProjectRoot: 'projects', projects: { 'angular-tic-tac-toe': { projectType: 'application', schematics: { '@schematics/angular:component': { style: 'scss' } }, root: '', sourceRoot: 'src', prefix: 'app', architect: { build: { builder: '@angular-builders/custom-webpack:browser', options: { customWebpackConfig: { path: './custom-webpack.config.ts' }, main: 'src/main.ts', index: 'src/index.html', tsConfig: 'tsconfig.app.json', outputPath: 'dist/angular-tic-tac-toe', polyfills: [ 'zone.js' ], assets: [ 'src/favicon.ico', 'src/assets', 'src/manifest.webmanifest' ], inlineStyleLanguage: 'scss', styles: [ 'node_modules/primeicons/primeicons.css', 'node_modules/primeng/resources/themes/lara-dark-blue/theme.css', 'node_modules/primeng/resources/primeng.min.css', 'src/styles.scss' ], scripts: [], serviceWorker: true, ngswConfigPath: 'ngsw-config.json' }, configurations: { production: { fileReplacements: [ { replace: 'src/environments/environment.ts', with: 'src/environments/environment.production.ts' } ], budgets: [ { type: 'initial', maximumWarning: '500kb', maximumError: '1mb' }, { type: 'anyComponentStyle', maximumWarning: '2kb', maximumError: '4kb' } ], outputHashing: 'all' }, development: { fileReplacements: [ { replace: 'src/environments/environment.ts', with: 'src/environments/environment.development.ts' } ], buildOptimizer: false, optimization: false, vendorChunk: true, extractLicenses: false, sourceMap: true, namedChunks: true } }, defaultConfiguration: 'production' }, serve: { builder: '@angular-builders/custom-webpack:dev-server', options: { browserTarget: 'angular-tic-tac-toe:build' }, configurations: { production: { browserTarget: 'angular-tic-tac-toe:build:production' }, development: { browserTarget: 'angular-tic-tac-toe:build:development' } }, defaultConfiguration: 'development' }, 'extract-i18n': { builder: '@angular-builders/custom-webpack:extract-i18n', options: { browserTarget: 'angular-tic-tac-toe:build' } }, lint: { builder: '@angular-eslint/builder:lint', options: { lintFilePatterns: [ 'src/**/*.ts', 'src/**/*.html' ] } }, deploy: { builder: '@angular/fire:deploy', options: { prerender: false, ssr: false, browserTarget: 'angular-tic-tac-toe:build:production', firebaseProject: 'angular-tic-tac-toe-eb2e5', firebaseHostingSite: 'angular-tic-tac-toe-eb2e5' } }, test: { builder: '@angular-builders/jest:run', options: { configPath: 'jest.config.angular.js', tsConfig: 'tsconfig.spec.json', assets: [ 'src/favicon.ico', 'src/assets' ], styles: [ 'src/styles.scss' ], scripts: [] } } } } }, cli: { schematicCollections: [ '@angular-eslint/schematics' ] } } }, jest: { config: { configs: [ { automock: false, cache: true, cacheDirectory: '/tmp/jest_rs', clearMocks: false, coveragePathIgnorePatterns: [ '/node_modules/' ], cwd: '/angular-project', dependencyExtractor: undefined, detectLeaks: false, detectOpenHandles: false, displayName: undefined, errorOnDeprecated: false, extensionsToTreatAsEsm: [], fakeTimers: { enableGlobally: false }, filter: undefined, forceCoverageMatch: [], globalSetup: undefined, globalTeardown: undefined, globals: {}, haste: { computeSha1: false, enableSymlinks: false, forceNodeFilesystemAPI: true, throwOnModuleCollision: false }, id: 'd7a3778b899cab780888cfa454968787', injectGlobals: true, moduleDirectories: [ 'node_modules' ], moduleFileExtensions: [ 'js', 'mjs', 'cjs', 'jsx', 'ts', 'tsx', 'json', 'node' ], moduleNameMapper: [], modulePathIgnorePatterns: [], modulePaths: undefined, prettierPath: 'prettier', resetMocks: false, resetModules: false, resolver: undefined, restoreMocks: false, rootDir: '/angular-project', roots: [ '/angular-project' ], runner: '/angular-project/node_modules/jest-runner/build/index.js', runtime: undefined, sandboxInjectedGlobals: [], setupFiles: [], setupFilesAfterEnv: [], skipFilter: false, skipNodeResolution: undefined, slowTestThreshold: 5, snapshotFormat: undefined, snapshotResolver: undefined, snapshotSerializers: [], testEnvironment: '/angular-project/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: '/angular-project/node_modules/jest-circus/runner.js', transform: [ [ '\\.[jt]sx?$', '/angular-project/node_modules/babel-jest/build/index.js', {} ] ], transformIgnorePatterns: [ '/node_modules/', '\\.pnp\\.[^\\/]+$' ], unmockedModulePathPatterns: undefined, watchPathIgnorePatterns: [] } ], globalConfig: { bail: 0, changedFilesWithAncestor: false, changedSince: undefined, ci: false, collectCoverage: false, collectCoverageFrom: [], collectCoverageOnlyFrom: undefined, coverageDirectory: '/angular-project/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: 7, noSCM: undefined, noStackTrace: false, nonFlagArgs: undefined, notify: false, notifyMode: 'failure-change', onlyChanged: false, onlyFailures: false, outputFile: undefined, passWithNoTests: false, projects: [], replname: undefined, reporters: undefined, rootDir: '/angular-project', runTestsByPath: false, shard: undefined, silent: undefined, skipFilter: false, snapshotFormat: undefined, testFailureExitCode: 1, testNamePattern: undefined, testPathPattern: '', testResultsProcessor: undefined, testSequencer: '/angular-project/node_modules/@jest/test-sequencer/build/index.js', testTimeout: undefined, updateSnapshot: 'new', useStderr: false, verbose: undefined, watch: false, watchAll: false, watchPlugins: undefined, watchman: true }, hasDeprecationWarnings: false, wallaby: { roots: [], watchPathIgnorePatterns: [ '/node_modules/', '\\./dist/|\\./build/|\\./coverage/|\\./git/|/\\..+/', '/tmp/jest_rs', '\\./coverage' ], testPathIgnorePatterns: [ '/node_modules/', '\\./dist/|\\./build/|\\./coverage/|\\./git/|/\\..+/', '/tmp/jest_rs', '\\./coverage' ], testMatch: [ '**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[tj]s?(x)' ], testRegex: [] } } } }, filesWithCoverageCalculated: [], filesWithNoCoverageCalculated: [], globalSetup: false, dot: true, customJestConfig: { configs: [ { automock: false, cache: true, cacheDirectory: '/tmp/jest_rs', clearMocks: false, coveragePathIgnorePatterns: [ '/node_modules/' ], cwd: '/angular-project', dependencyExtractor: undefined, detectLeaks: false, detectOpenHandles: false, displayName: undefined, errorOnDeprecated: false, extensionsToTreatAsEsm: [], fakeTimers: { enableGlobally: false }, filter: undefined, forceCoverageMatch: [], globalSetup: undefined, globalTeardown: undefined, globals: {}, haste: { computeSha1: false, enableSymlinks: false, forceNodeFilesystemAPI: true, throwOnModuleCollision: false }, id: 'd7a3778b899cab780888cfa454968787', injectGlobals: true, moduleDirectories: [ 'node_modules' ], moduleFileExtensions: [ 'js', 'mjs', 'cjs', 'jsx', 'ts', 'tsx', 'json', 'node' ], moduleNameMapper: [], modulePathIgnorePatterns: [], modulePaths: undefined, prettierPath: 'prettier', resetMocks: false, resetModules: false, resolver: undefined, restoreMocks: false, rootDir: '/angular-project', roots: [ '/angular-project' ], runner: '/angular-project/node_modules/jest-runner/build/index.js', runtime: undefined, sandboxInjectedGlobals: [], setupFiles: [], setupFilesAfterEnv: [], skipFilter: false, skipNodeResolution: undefined, slowTestThreshold: 5, snapshotFormat: undefined, snapshotResolver: undefined, snapshotSerializers: [], testEnvironment: '/angular-project/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: '/angular-project/node_modules/jest-circus/runner.js', transform: [ [ '\\.[jt]sx?$', '/angular-project/node_modules/babel-jest/build/index.js', {} ] ], transformIgnorePatterns: [ '/node_modules/', '\\.pnp\\.[^\\/]+$' ], unmockedModulePathPatterns: undefined, watchPathIgnorePatterns: [] } ], globalConfig: { bail: 0, changedFilesWithAncestor: false, changedSince: undefined, ci: false, collectCoverage: false, collectCoverageFrom: [], collectCoverageOnlyFrom: undefined, coverageDirectory: '/angular-project/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: 7, noSCM: undefined, noStackTrace: false, nonFlagArgs: undefined, notify: false, notifyMode: 'failure-change', onlyChanged: false, onlyFailures: false, outputFile: undefined, passWithNoTests: false, projects: [], replname: undefined, reporters: undefined, rootDir: '/angular-project', runTestsByPath: false, shard: undefined, silent: undefined, skipFilter: false, snapshotFormat: undefined, testFailureExitCode: 1, testNamePattern: undefined, testPathPattern: '', testResultsProcessor: undefined, testSequencer: '/angular-project/node_modules/@jest/test-sequencer/build/index.js', testTimeout: undefined, updateSnapshot: 'new', useStderr: false, verbose: undefined, watch: false, watchAll: false, watchPlugins: undefined, watchman: true }, hasDeprecationWarnings: false, wallaby: { roots: [], watchPathIgnorePatterns: [ '/node_modules/', '\\./dist/|\\./build/|\\./coverage/|\\./git/|/\\..+/', '/tmp/jest_rs', '\\./coverage' ], testPathIgnorePatterns: [ '/node_modules/', '\\./dist/|\\./build/|\\./coverage/|\\./git/|/\\..+/', '/tmp/jest_rs', '\\./coverage' ], testMatch: [ '**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[tj]s?(x)' ], testRegex: [] } }, 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: '/tmp/jest_rs', regexp: /\/tmp\/jest_rs/, 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 } ], 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: '/tmp/jest_rs', regexp: /\/tmp\/jest_rs/, 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: {}, smartStart: [ { test: true, source: false, pattern: '**/*', startMode: 'open' }, { test: false, source: true, pattern: '**/*', startMode: 'edit' } ], 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/', ignoreCoverageForFile: '__REGEXP /ignore file coverage/', commentAutoLog: '?', testFileSelection: { include: '__REGEXP /file\\.only/', exclude: '__REGEXP /file\\.skip/' } }, automaticTestFileSelection: true, runSelectedTestsOnly: true, mapConsoleMessagesStackTrace: false, extensions: {}, env: { type: 'node', params: {}, runner: '/.asdf/installs/nodejs/16.17.0/bin/node', viewportSize: { width: 800, height: 600 }, options: { width: 800, height: 600 }, bundle: true }, reportUnhandledPromises: true, slowTestThreshold: 75, lowCoverageThreshold: 80, runAllTestsWhenNoAffectedTests: false, configCode: 'module.exports = function () {\n' + ' return {\n' + ' // env: {\n' + " // type: 'node',\n" + ' // },\n' + ' testFramework: {\n' + " configFile: './jest.config.angular.js',\n" + ' },\n' + '\n' + ' /*\n' + " // testFramework: 'jest',\n" + ' // setup: function (wallaby) {\n' + " // const jestConfig = require('./jest.config.angular');\n" + ' // // @ts-ignore\n' + ' // delete jestConfig.transform;\n' + ' // wallaby.testFramework.configure(jestConfig);\n' + ' // },\n' + ' */\n' + '\n' + ' // files: [\n' + " // // './src/app/**/*.ts',\n" + " // 'src/**/*.+(ts|html|json|snap|css|less|sass|scss|jpg|jpeg|gif|png|svg)',\n" + " // 'tsconfig.json',\n" + " // 'jest.config.angular.js',\n" + " // 'tsconfig.spec.json',\n" + " // '!./src/app/**/*.{spec,test}.ts',\n" + " // '!**/node_modules/**/*',\n" + ' // ],\n' + " // tests: ['./src/app/**/*.{spec,test}.ts', '!**/node_modules/**/*'],\n" + ' // hints: {\n' + ' // ignoreCoverageForFile: /Wallaby ignore file coverage/,\n' + ' // ignoreCoverage: /Wallaby ignore coverage/,\n' + ' // },\n' + ' // trace: true,\n' + ' };\n' + '};\n', testLocations: [ 'src/app/app.component.spec.ts' ] }, packageJSON: { dependencies: { '@angular/animations': '^15.0.0', '@angular/common': '^15.0.0', '@angular/compiler': '^15.0.0', '@angular/core': '^15.0.0', '@angular/fire': '^7.5.0', '@angular/forms': '^15.0.0', '@angular/platform-browser': '^15.0.0', '@angular/platform-browser-dynamic': '^15.0.0', '@angular/router': '^15.0.0', '@angular/service-worker': '^15.0.0', memoizee: '^0.4.15', primeicons: '^6.0.1', primeng: '^15.0.1', rxjs: '~7.5.0', tslib: '^2.3.0', 'zone.js': '~0.12.0' }, devDependencies: { '@angular-builders/custom-webpack': '^15.0.0', '@angular-builders/jest': '15.0.0', '@angular-devkit/build-angular': '^15.0.4', '@angular-eslint/builder': '15.1.0', '@angular-eslint/eslint-plugin': '15.1.0', '@angular-eslint/eslint-plugin-template': '15.1.0', '@angular-eslint/schematics': '15.1.0', '@angular-eslint/template-parser': '15.1.0', '@angular/cli': '~15.0.4', '@angular/compiler-cli': '^15.0.0', '@faker-js/faker': '7.6.0', '@fast-check/jest': '1.6.0', '@istanbuljs/nyc-config-typescript': '1.0.2', '@istanbuljs/schema': '0.1.3', '@stryker-mutator/core': '6.3.1', '@stryker-mutator/jest-runner': '6.3.1', '@stryker-mutator/typescript-checker': '6.3.1', '@types/jest': '29.2.5', '@types/memoizee': '^0.4.8', '@typescript-eslint/eslint-plugin': '5.44.0', '@typescript-eslint/parser': '5.44.0', dotenv: '^16.0.3', eslint: '^8.28.0', 'eslint-config-prettier': '^8.6.0', 'eslint-plugin-prettier': '^4.2.1', 'fast-check': '3.5.0', jest: '28.1.3', 'lint-staged': '13.1.0', nodemon: '2.0.20', prettier: '^2.8.2', 'source-map-explorer': '^2.5.3', 'tsconfig-paths': '4.1.2', typescript: '~4.8.2', 'webpack-bundle-analyzer': '^4.7.0' } }, fs: { numberOfFiles: 91 }, debug: [ '2023-01-11T07:53:13.628Z config Attempting automatic configuration for angular\n', '2023-01-11T07:53:13.632Z angular/cli config Detected Angular CLI.\n', '2023-01-11T07:53:13.633Z angular/cli config Angular currentDirPath: "/angular-project", workspaceDirPath: "/angular-project"\n', '2023-01-11T07:53:14.365Z jest/config Detected Jest.\n', '2023-01-11T07:53:14.366Z jest/config Configured Jest.\n', '2023-01-11T07:53:14.366Z config Finished attempting automatic configuration for angular (738ms)\n', '2023-01-11T07:53:14.368Z project Wallaby Node version: v16.17.0\n', '2023-01-11T07:53:14.368Z project Wallaby config: /angular-project/wallaby.js\n', '2023-01-11T07:53:14.382Z fs File system starting\n', '2023-01-11T07:53:14.513Z fs File system scan completed\n', '2023-01-11T07:53:14.526Z project File cache: /.vscode/extensions/wallabyjs.wallaby-vscode-1.0.348/projects/6f7d19d3cbb9b0a3\n', '2023-01-11T07:53:14.633Z uiService Listening port 51235\n', '2023-01-11T07:53:14.648Z workers Parallelism for initial run: 6, for regular run: 3\n', '2023-01-11T07:53:14.648Z workers Starting run worker instance #0\n', '2023-01-11T07:53:14.649Z workers Starting run worker instance #1\n', '2023-01-11T07:53:14.649Z workers Starting run worker instance #2\n', '2023-01-11T07:53:14.649Z workers Starting run worker instance #3\n', '2023-01-11T07:53:14.649Z workers Starting run worker instance #4\n', '2023-01-11T07:53:14.649Z workers Starting run worker instance #5\n', '2023-01-11T07:53:14.649Z workers Web server is listening at 43533\n', '2023-01-11T07:53:14.727Z project Stopping process pool\n', '2023-01-11T07:53:14.727Z project File cache is up-to-date, starting full test run\n', '2023-01-11T07:53:14.731Z project Test run started; run priority: 3\n', '2023-01-11T07:53:14.735Z project Running all tests\n', '2023-01-11T07:53:14.740Z project Test run finished\n', '2023-01-11T07:53:14.740Z project Test run data re-queued\n', '2023-01-11T07:53:14.877Z workers Started run worker instance (delayed) #0\n', '2023-01-11T07:53:14.906Z workers Started run worker instance (delayed) #1\n', '2023-01-11T07:53:14.925Z workers Started run worker instance (delayed) #2\n', '2023-01-11T07:53:14.930Z workers Started run worker instance (delayed) #3\n', '2023-01-11T07:53:14.970Z workers Started run worker instance (delayed) #4\n', '2023-01-11T07:53:14.985Z workers Started run worker instance (delayed) #5\n', '2023-01-11T07:53:16.846Z project Requested to run all tests\n', '2023-01-11T07:53:16.846Z project Test run started; run priority: 3\n', '2023-01-11T07:53:16.847Z project Running all tests\n', '2023-01-11T07:53:16.850Z workers Starting test run, priority: 3\n', '2023-01-11T07:53:16.850Z nodeRunner Starting sandbox [worker #0, session #29s1p]\n', '2023-01-11T07:53:16.850Z nodeRunner Preparing sandbox [worker #0, session #29s1p]\n', '2023-01-11T07:53:16.850Z nodeRunner Prepared sandbox [worker #0, session #29s1p]\n', '2023-01-11T07:53:16.850Z workers [worker #0, session #29s1p] Running tests in sandbox\n', '2023-01-11T07:53:18.053Z workers Scheduling Jest Test Run (29s1p): 2023-01-11T07:53:17.480Z\n', '2023-01-11T07:53:18.059Z workers Sandbox (active) [29s1p] error: Jest encountered an unexpected token\n' + '\n' + 'Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.\n' + '\n' + 'Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.\n' + '\n' + 'By default "node_modules" folder is ignored by transformers.\n' + '\n' + "Here's what you can do:\n" + ' • If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/ecmascript-modules for how to enable it.\n' + ' • If you are trying to use TypeScript, see https://jestjs.io/docs/getting-started#using-typescript\n' + ' • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.\n' + ' • If you need a custom transformation specify a "transform" option in your config.\n' + ' • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.\n' + '\n' + "You'll find more details and examples of these config options in the docs:\n" + 'https://jestjs.io/docs/configuration\n' + 'For information about custom transformations, see:\n' + 'https://jestjs.io/docs/code-transformation\n' + '\n' + 'Details:\n' + '\n' + './src/app/app.component.spec.ts:2\n' + 'import {\n' + '^^^^^^\n' + '\n' + 'SyntaxError: Cannot use import statement outside a module\n' + ' at new Script (node:vm:100:7)\n' + ' at Runtime.createScriptFromCode (./node_modules/jest-runtime/build/index.js:1796:14)\n' + ' at Runtime._execModule (./node_modules/jest-runtime/build/index.js:1664:25)\n' + ' at Runtime._loadModule (./node_modules/jest-runtime/build/index.js:1223:12)\n' + ' at Runtime.requireModule (./node_modules/jest-runtime/build/index.js:1047:12)\n' + ' at jestAdapter (./node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:89:13)\n' + ' at runTestInternal (./node_modules/jest-runner/build/runTest.js:411:16)\n' + ' at runTest (./node_modules/jest-runner/build/runTest.js:499:34)\n', '2023-01-11T07:53:18.064Z workers [29s1p] Run 0 test(s), skipped 0 test(s)\n', '2023-01-11T07:53:18.065Z workers Jest Test Run Complete (29s1p): 2023-01-11T07:53:18.045Z\n', '2023-01-11T07:53:18.069Z workers [29s1p] Sandbox is responsive, closing it\n', '2023-01-11T07:53:18.072Z project Test run finished\n', '2023-01-11T07:53:18.073Z project Processed console.log entries\n', '2023-01-11T07:53:18.073Z project Processed loading sequences\n', '2023-01-11T07:53:18.073Z project Processed executed tests\n', '2023-01-11T07:53:18.074Z project Processed code coverage\n', '2023-01-11T07:53:18.089Z project Test run result processed and sent to IDE\n' ] } ```
NikGovorov commented 1 year ago

You require ts-jest in jest.config.angular.js but it's not installed as a dependency in package.json. Could you please provide us with a working sample project demonstrating the issue?

node-ex commented 1 year ago

Yes, I will create a working sample project, perhaps will find the root cause in the process 😄

node-ex commented 1 year ago

Here is a repository with a minimalistic working sample project: https://github.com/node-ex/angular-jest-wallaby-setup-sample-project

In this project Wallaby.js output still mentions that Jest is unable to parse test file, but this time it cannot handle type annotation, not the very first import as in my original case.

I've provided information about the setup, all performed steps, and result in the README.md.

Wallaby diagnosti report for this sample project ``` { editorVersion: '1.74.2', pluginVersion: '1.0.348', editorType: 'VSCode', osVersion: 'linux 5.4.0-135-generic', nodeVersion: 'v16.17.0', coreVersion: '1.0.1367', checksum: 'NjU0ZjZhMmY2NWM4ZWExMGIyZDYyMmIxYWQxNDVmMDgsMTcwMDc4NDAwMDAwMCww', config: { testFramework: { version: 'jest@24.8.0', configurator: 'jest@24.8.0', reporter: 'jest@24.8.0', starter: 'jest@24.8.0', configFile: './jest.config.js', autoDetected: true }, trace: true, diagnostics: { angular: { workspace: { '$schema': './node_modules/@angular/cli/lib/config/schema.json', version: 1, newProjectRoot: 'projects', projects: { 'angular-jest-wallaby-setup-sample-project': { projectType: 'application', schematics: {}, root: '', sourceRoot: 'src', prefix: 'app', architect: { build: { builder: '@angular-devkit/build-angular:browser', options: { outputPath: 'dist/angular-jest-wallaby-setup-sample-project', index: 'src/index.html', main: 'src/main.ts', polyfills: [ 'zone.js' ], tsConfig: 'tsconfig.app.json', assets: [ 'src/favicon.ico', 'src/assets' ], styles: [ 'src/styles.css' ], scripts: [] }, configurations: { production: { budgets: [ { type: 'initial', maximumWarning: '500kb', maximumError: '1mb' }, { type: 'anyComponentStyle', maximumWarning: '2kb', maximumError: '4kb' } ], outputHashing: 'all' }, development: { buildOptimizer: false, optimization: false, vendorChunk: true, extractLicenses: false, sourceMap: true, namedChunks: true } }, defaultConfiguration: 'production' }, serve: { builder: '@angular-devkit/build-angular:dev-server', configurations: { production: { browserTarget: 'angular-jest-wallaby-setup-sample-project:build:production' }, development: { browserTarget: 'angular-jest-wallaby-setup-sample-project:build:development' } }, defaultConfiguration: 'development' }, 'extract-i18n': { builder: '@angular-devkit/build-angular:extract-i18n', options: { browserTarget: 'angular-jest-wallaby-setup-sample-project:build' } }, test: { builder: '@angular-builders/jest:run', options: { tsConfig: 'tsconfig.spec.json', assets: [ 'src/favicon.ico', 'src/assets' ], styles: [ 'src/styles.css' ], scripts: [] } } } } } } }, jest: { config: { configs: [ { automock: false, cache: true, cacheDirectory: '/tmp/jest_rs', clearMocks: false, coveragePathIgnorePatterns: [ '/node_modules/' ], cwd: '/angular-jest-wallaby-setup-sample-project', dependencyExtractor: undefined, detectLeaks: false, detectOpenHandles: false, displayName: undefined, errorOnDeprecated: false, extensionsToTreatAsEsm: [], fakeTimers: { enableGlobally: false }, filter: undefined, forceCoverageMatch: [], globalSetup: undefined, globalTeardown: undefined, globals: {}, haste: { computeSha1: false, enableSymlinks: false, forceNodeFilesystemAPI: true, throwOnModuleCollision: false }, id: '569f3716c56642047fbe4717d7bdef81', injectGlobals: true, moduleDirectories: [ 'node_modules' ], moduleFileExtensions: [ 'js', 'mjs', 'cjs', 'jsx', 'ts', 'tsx', 'json', 'node' ], moduleNameMapper: [], modulePathIgnorePatterns: [], modulePaths: undefined, prettierPath: 'prettier', resetMocks: false, resetModules: false, resolver: undefined, restoreMocks: false, rootDir: '/angular-jest-wallaby-setup-sample-project', roots: [ '/angular-jest-wallaby-setup-sample-project' ], runner: '/angular-jest-wallaby-setup-sample-project/node_modules/jest-runner/build/index.js', runtime: undefined, sandboxInjectedGlobals: [], setupFiles: [], setupFilesAfterEnv: [], skipFilter: false, skipNodeResolution: undefined, slowTestThreshold: 5, snapshotFormat: undefined, snapshotResolver: undefined, snapshotSerializers: [], testEnvironment: '/angular-jest-wallaby-setup-sample-project/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: '/angular-jest-wallaby-setup-sample-project/node_modules/jest-circus/runner.js', transform: [ [ '\\.[jt]sx?$', '/angular-jest-wallaby-setup-sample-project/node_modules/babel-jest/build/index.js', {} ] ], transformIgnorePatterns: [ '/node_modules/', '\\.pnp\\.[^\\/]+$' ], unmockedModulePathPatterns: undefined, watchPathIgnorePatterns: [] } ], globalConfig: { bail: 0, changedFilesWithAncestor: false, changedSince: undefined, ci: false, collectCoverage: false, collectCoverageFrom: [], collectCoverageOnlyFrom: undefined, coverageDirectory: '/angular-jest-wallaby-setup-sample-project/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: 7, noSCM: undefined, noStackTrace: false, nonFlagArgs: undefined, notify: false, notifyMode: 'failure-change', onlyChanged: false, onlyFailures: false, outputFile: undefined, passWithNoTests: false, projects: [], replname: undefined, reporters: undefined, rootDir: '/angular-jest-wallaby-setup-sample-project', runTestsByPath: false, shard: undefined, silent: undefined, skipFilter: false, snapshotFormat: undefined, testFailureExitCode: 1, testNamePattern: undefined, testPathPattern: '', testResultsProcessor: undefined, testSequencer: '/angular-jest-wallaby-setup-sample-project/node_modules/@jest/test-sequencer/build/index.js', testTimeout: undefined, updateSnapshot: 'new', useStderr: false, verbose: undefined, watch: false, watchAll: false, watchPlugins: undefined, watchman: true }, hasDeprecationWarnings: false, wallaby: { roots: [], watchPathIgnorePatterns: [ '/node_modules/', '\\./dist/|\\./build/|\\./coverage/|\\./git/|/\\..+/', '/tmp/jest_rs', '\\./coverage' ], testPathIgnorePatterns: [ '/node_modules/', '\\./dist/|\\./build/|\\./coverage/|\\./git/|/\\..+/', '/tmp/jest_rs', '\\./coverage' ], testMatch: [ '**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[tj]s?(x)' ], testRegex: [] } } } }, filesWithCoverageCalculated: [], filesWithNoCoverageCalculated: [], globalSetup: false, dot: true, customJestConfig: { configs: [ { automock: false, cache: true, cacheDirectory: '/tmp/jest_rs', clearMocks: false, coveragePathIgnorePatterns: [ '/node_modules/' ], cwd: '/angular-jest-wallaby-setup-sample-project', dependencyExtractor: undefined, detectLeaks: false, detectOpenHandles: false, displayName: undefined, errorOnDeprecated: false, extensionsToTreatAsEsm: [], fakeTimers: { enableGlobally: false }, filter: undefined, forceCoverageMatch: [], globalSetup: undefined, globalTeardown: undefined, globals: {}, haste: { computeSha1: false, enableSymlinks: false, forceNodeFilesystemAPI: true, throwOnModuleCollision: false }, id: '569f3716c56642047fbe4717d7bdef81', injectGlobals: true, moduleDirectories: [ 'node_modules' ], moduleFileExtensions: [ 'js', 'mjs', 'cjs', 'jsx', 'ts', 'tsx', 'json', 'node' ], moduleNameMapper: [], modulePathIgnorePatterns: [], modulePaths: undefined, prettierPath: 'prettier', resetMocks: false, resetModules: false, resolver: undefined, restoreMocks: false, rootDir: '/angular-jest-wallaby-setup-sample-project', roots: [ '/angular-jest-wallaby-setup-sample-project' ], runner: '/angular-jest-wallaby-setup-sample-project/node_modules/jest-runner/build/index.js', runtime: undefined, sandboxInjectedGlobals: [], setupFiles: [], setupFilesAfterEnv: [], skipFilter: false, skipNodeResolution: undefined, slowTestThreshold: 5, snapshotFormat: undefined, snapshotResolver: undefined, snapshotSerializers: [], testEnvironment: '/angular-jest-wallaby-setup-sample-project/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: '/angular-jest-wallaby-setup-sample-project/node_modules/jest-circus/runner.js', transform: [ [ '\\.[jt]sx?$', '/angular-jest-wallaby-setup-sample-project/node_modules/babel-jest/build/index.js', {} ] ], transformIgnorePatterns: [ '/node_modules/', '\\.pnp\\.[^\\/]+$' ], unmockedModulePathPatterns: undefined, watchPathIgnorePatterns: [] } ], globalConfig: { bail: 0, changedFilesWithAncestor: false, changedSince: undefined, ci: false, collectCoverage: false, collectCoverageFrom: [], collectCoverageOnlyFrom: undefined, coverageDirectory: '/angular-jest-wallaby-setup-sample-project/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: 7, noSCM: undefined, noStackTrace: false, nonFlagArgs: undefined, notify: false, notifyMode: 'failure-change', onlyChanged: false, onlyFailures: false, outputFile: undefined, passWithNoTests: false, projects: [], replname: undefined, reporters: undefined, rootDir: '/angular-jest-wallaby-setup-sample-project', runTestsByPath: false, shard: undefined, silent: undefined, skipFilter: false, snapshotFormat: undefined, testFailureExitCode: 1, testNamePattern: undefined, testPathPattern: '', testResultsProcessor: undefined, testSequencer: '/angular-jest-wallaby-setup-sample-project/node_modules/@jest/test-sequencer/build/index.js', testTimeout: undefined, updateSnapshot: 'new', useStderr: false, verbose: undefined, watch: false, watchAll: false, watchPlugins: undefined, watchman: true }, hasDeprecationWarnings: false, wallaby: { roots: [], watchPathIgnorePatterns: [ '/node_modules/', '\\./dist/|\\./build/|\\./coverage/|\\./git/|/\\..+/', '/tmp/jest_rs', '\\./coverage' ], testPathIgnorePatterns: [ '/node_modules/', '\\./dist/|\\./build/|\\./coverage/|\\./git/|/\\..+/', '/tmp/jest_rs', '\\./coverage' ], testMatch: [ '**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[tj]s?(x)' ], testRegex: [] } }, 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: '/tmp/jest_rs', regexp: /\/tmp\/jest_rs/, 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 } ], 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: '/tmp/jest_rs', regexp: /\/tmp\/jest_rs/, 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/', 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: '/.asdf/installs/nodejs/16.17.0/bin/node', viewportSize: { width: 800, height: 600 }, options: { width: 800, height: 600 }, bundle: true }, reportUnhandledPromises: true, slowTestThreshold: 75, lowCoverageThreshold: 80, runAllTestsWhenNoAffectedTests: false, configCode: "module.exports = () => {\n return {\n testFramework: {\n configFile: './jest.config.js'\n },\n trace: true\n }\n};\n" }, packageJSON: { dependencies: { '@angular/animations': '^15.0.0', '@angular/common': '^15.0.0', '@angular/compiler': '^15.0.0', '@angular/core': '^15.0.0', '@angular/forms': '^15.0.0', '@angular/platform-browser': '^15.0.0', '@angular/platform-browser-dynamic': '^15.0.0', '@angular/router': '^15.0.0', rxjs: '~7.5.0', tslib: '^2.3.0', 'zone.js': '~0.12.0' }, devDependencies: { '@angular-builders/jest': '15.0.0', '@angular-devkit/build-angular': '^15.0.4', '@angular/cli': '~15.0.4', '@angular/compiler-cli': '^15.0.0', '@briebug/jest-schematic': '^6.0.0', '@types/jest': '29.2.5', jest: '28.1.3', typescript: '~4.8.2' } }, fs: { numberOfFiles: 22 }, debug: [ '2023-01-12T19:00:18.706Z config Attempting automatic configuration for angular\n', '2023-01-12T19:00:18.712Z angular/cli config Detected Angular CLI.\n', '2023-01-12T19:00:18.714Z angular/cli config Angular currentDirPath: "/angular-jest-wallaby-setup-sample-project", workspaceDirPath: "/angular-jest-wallaby-setup-sample-project"\n', '2023-01-12T19:00:19.858Z jest/config Detected Jest.\n', '2023-01-12T19:00:19.859Z jest/config Configured Jest.\n', '2023-01-12T19:00:19.859Z config Finished attempting automatic configuration for angular (1153ms)\n', '2023-01-12T19:00:19.862Z project Wallaby Node version: v16.17.0\n', '2023-01-12T19:00:19.862Z project Wallaby config: /angular-jest-wallaby-setup-sample-project/wallaby.js\n', '2023-01-12T19:00:19.882Z fs File system starting\n', '2023-01-12T19:00:19.956Z fs File system scan completed\n', '2023-01-12T19:00:19.975Z project File cache: /.vscode/extensions/wallabyjs.wallaby-vscode-1.0.348/projects/abbdad3766d0c561\n', '2023-01-12T19:00:19.988Z uiService Listening port 51236\n', '2023-01-12T19:00:19.995Z project package.json file change detected, invalidating local cache\n', '2023-01-12T19:00:20.015Z workers Parallelism for initial run: 6, for regular run: 3\n', '2023-01-12T19:00:20.016Z workers Starting run worker instance #0\n', '2023-01-12T19:00:20.016Z workers Starting run worker instance #1\n', '2023-01-12T19:00:20.016Z workers Starting run worker instance #2\n', '2023-01-12T19:00:20.017Z workers Starting run worker instance #3\n', '2023-01-12T19:00:20.017Z workers Starting run worker instance #4\n', '2023-01-12T19:00:20.017Z workers Starting run worker instance #5\n', '2023-01-12T19:00:20.018Z workers Web server is listening at 46537\n', '2023-01-12T19:00:20.018Z project File cache requires some updates, waiting required files from IDE\n', '2023-01-12T19:00:20.142Z project Stopping process pool\n', '2023-01-12T19:00:20.144Z project Test run started; run priority: 3\n', '2023-01-12T19:00:20.146Z project Running all tests\n', '2023-01-12T19:00:20.148Z workers Starting test run, priority: 3\n', '2023-01-12T19:00:20.149Z nodeRunner Starting sandbox [worker #0, session #eao4q]\n', '2023-01-12T19:00:20.149Z nodeRunner Preparing sandbox [worker #0, session #eao4q]\n', '2023-01-12T19:00:20.353Z workers Started run worker instance (delayed) #2\n', '2023-01-12T19:00:20.363Z workers Started run worker instance (delayed) #0\n', '2023-01-12T19:00:20.364Z nodeRunner Prepared sandbox [worker #0, session #eao4q]\n', '2023-01-12T19:00:20.365Z workers [worker #0, session #eao4q] Running tests in sandbox\n', '2023-01-12T19:00:20.369Z workers Started run worker instance (delayed) #1\n', '2023-01-12T19:00:20.400Z workers Started run worker instance (delayed) #3\n', '2023-01-12T19:00:20.429Z workers Started run worker instance (delayed) #4\n', '2023-01-12T19:00:20.459Z workers Started run worker instance (delayed) #5\n', '2023-01-12T19:00:22.166Z workers Scheduling Jest Test Run (eao4q): 2023-01-12T19:00:20.890Z\n', '2023-01-12T19:00:22.179Z workers Sandbox (active) [eao4q] error: Jest encountered an unexpected token\n' + '\n' + 'Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.\n' + '\n' + 'Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.\n' + '\n' + 'By default "node_modules" folder is ignored by transformers.\n' + '\n' + "Here's what you can do:\n" + ' • If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/ecmascript-modules for how to enable it.\n' + ' • If you are trying to use TypeScript, see https://jestjs.io/docs/getting-started#using-typescript\n' + ' • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.\n' + ' • If you need a custom transformation specify a "transform" option in your config.\n' + ' • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.\n' + '\n' + "You'll find more details and examples of these config options in the docs:\n" + 'https://jestjs.io/docs/configuration\n' + 'For information about custom transformations, see:\n' + 'https://jestjs.io/docs/code-transformation\n' + '\n' + 'Details:\n' + '\n' + 'SyntaxError: ./src/app/app.component.spec.ts: Missing initializer in const declaration. (14:17)\n' + '\n' + ' 12 |\n' + " 13 | it('should create the app', () => {\n" + '> 14 | const fixture: ComponentFixture = TestBed.createComponent(AppComponent);\n' + ' | ^\n' + ' 15 | const app: AppComponent = fixture.componentInstance;\n' + ' 16 | expect(app).toBeTruthy();\n' + ' 17 | });\n' + ' at instantiate (./node_modules/@babel/parser/src/parse-error/credentials.ts:62:21)\n' + ' at instantiate (./node_modules/@babel/parser/src/parse-error.ts:60:12)\n' + ' at Parser.toParseError [as raise] (./node_modules/@babel/parser/src/tokenizer/index.ts:1456:19)\n' + ' at Parser.raise [as parseVar] (./node_modules/@babel/parser/src/parser/statement.ts:1493:16)\n' + ' at Parser.parseVar [as parseVarStatement] (./node_modules/@babel/parser/src/parser/statement.ts:1138:10)\n' + ' at Parser.parseVarStatement [as parseStatementContent] (./node_modules/@babel/parser/src/parser/statement.ts:524:21)\n' + ' at Parser.parseStatementContent [as parseStatementLike] (./node_modules/@babel/parser/src/parser/statement.ts:406:17)\n' + ' at Parser.parseStatementLike [as parseStatementListItem] (./node_modules/@babel/parser/src/parser/statement.ts:361:17)\n' + ' at Parser.parseStatementListItem [as parseBlockOrModuleBlockBody] (./node_modules/@babel/parser/src/parser/statement.ts:1332:16)\n' + ' at Parser.parseBlockOrModuleBlockBody [as parseBlockBody] (./node_modules/@babel/parser/src/parser/statement.ts:1305:10)\n' + ' at Parser.parseBlockBody [as parseBlock] (./node_modules/@babel/parser/src/parser/statement.ts:1273:10)\n' + ' at Parser.parseBlock [as parseFunctionBody] (./node_modules/@babel/parser/src/parser/expression.ts:2556:24)\n' + ' at Parser.parseFunctionBody [as parseArrowExpression] (./node_modules/@babel/parser/src/parser/expression.ts:2501:10)\n' + ' at Parser.parseArrowExpression [as parseParenAndDistinguishExpression] (./node_modules/@babel/parser/src/parser/expression.ts:1798:12)\n' + ' at Parser.parseParenAndDistinguishExpression [as parseExprAtom] (./node_modules/@babel/parser/src/parser/expression.ts:1161:21)\n' + ' at Parser.parseExprAtom [as parseExprSubscripts] (./node_modules/@babel/parser/src/parser/expression.ts:721:23)\n' + ' at Parser.parseExprSubscripts [as parseUpdate] (./node_modules/@babel/parser/src/parser/expression.ts:698:21)\n' + ' at Parser.parseUpdate [as parseMaybeUnary] (./node_modules/@babel/parser/src/parser/expression.ts:660:23)\n' + ' at Parser.parseMaybeUnary [as parseMaybeUnaryOrPrivate] (./node_modules/@babel/parser/src/parser/expression.ts:398:14)\n' + ' at Parser.parseMaybeUnaryOrPrivate [as parseExprOps] (./node_modules/@babel/parser/src/parser/expression.ts:410:23)\n' + ' at Parser.parseExprOps [as parseMaybeConditional] (./node_modules/@babel/parser/src/parser/expression.ts:365:23)\n' + ' at Parser.parseMaybeConditional [as parseMaybeAssign] (./node_modules/@babel/parser/src/parser/expression.ts:305:21)\n' + ' at parseMaybeAssign (./node_modules/@babel/parser/src/parser/expression.ts:259:12)\n' + ' at Parser.callback [as allowInAnd] (./node_modules/@babel/parser/src/parser/expression.ts:3082:12)\n' + ' at Parser.allowInAnd [as parseMaybeAssignAllowIn] (./node_modules/@babel/parser/src/parser/expression.ts:258:17)\n' + ' at Parser.parseMaybeAssignAllowIn [as parseExprListItem] (./node_modules/@babel/parser/src/parser/expression.ts:2718:18)\n' + ' at Parser.parseExprListItem [as parseCallExpressionArguments] (./node_modules/@babel/parser/src/parser/expression.ts:1042:14)\n' + ' at Parser.parseCallExpressionArguments [as parseCoverCallAndAsyncArrowHead] (./node_modules/@babel/parser/src/parser/expression.ts:892:29)\n' + ' at Parser.parseCoverCallAndAsyncArrowHead [as parseSubscript] (./node_modules/@babel/parser/src/parser/expression.ts:781:19)\n' + ' at Parser.parseSubscript [as parseSubscripts] (./node_modules/@babel/parser/src/parser/expression.ts:742:19)\n' + ' at Parser.parseSubscripts [as parseExprSubscripts] (./node_modules/@babel/parser/src/parser/expression.ts:727:17)\n' + ' at Parser.parseExprSubscripts [as parseUpdate] (./node_modules/@babel/parser/src/parser/expression.ts:698:21)\n' + ' at Parser.parseUpdate [as parseMaybeUnary] (./node_modules/@babel/parser/src/parser/expression.ts:660:23)\n' + ' at Parser.parseMaybeUnary [as parseMaybeUnaryOrPrivate] (./node_modules/@babel/parser/src/parser/expression.ts:398:14)\n' + ' at Parser.parseMaybeUnaryOrPrivate [as parseExprOps] (./node_modules/@babel/parser/src/parser/expression.ts:410:23)\n' + ' at Parser.parseExprOps [as parseMaybeConditional] (./node_modules/@babel/parser/src/parser/expression.ts:365:23)\n' + ' at Parser.parseMaybeConditional [as parseMaybeAssign] (./node_modules/@babel/parser/src/parser/expression.ts:305:21)\n' + ' at Parser.parseMaybeAssign [as parseExpressionBase] (./node_modules/@babel/parser/src/parser/expression.ts:228:23)\n' + ' at parseExpressionBase (./node_modules/@babel/parser/src/parser/expression.ts:219:39)\n' + ' at Parser.callback [as allowInAnd] (./node_modules/@babel/parser/src/parser/expression.ts:3077:16)\n' + ' at Parser.allowInAnd [as parseExpression] (./node_modules/@babel/parser/src/parser/expression.ts:219:17)\n' + ' at Parser.parseExpression [as parseStatementContent] (./node_modules/@babel/parser/src/parser/statement.ts:615:23)\n' + ' at Parser.parseStatementContent [as parseStatementLike] (./node_modules/@babel/parser/src/parser/statement.ts:406:17)\n' + ' at Parser.parseStatementLike [as parseStatementListItem] (./node_modules/@babel/parser/src/parser/statement.ts:361:17)\n' + ' at Parser.parseStatementListItem [as parseBlockOrModuleBlockBody] (./node_modules/@babel/parser/src/parser/statement.ts:1332:16)\n' + ' at Parser.parseBlockOrModuleBlockBody [as parseBlockBody] (./node_modules/@babel/parser/src/parser/statement.ts:1305:10)\n' + ' at Parser.parseBlockBody [as parseBlock] (./node_modules/@babel/parser/src/parser/statement.ts:1273:10)\n' + ' at Parser.parseBlock [as parseFunctionBody] (./node_modules/@babel/parser/src/parser/expression.ts:2556:24)\n' + ' at Parser.parseFunctionBody [as parseArrowExpression] (./node_modules/@babel/parser/src/parser/expression.ts:2501:10)\n' + ' at Parser.parseArrowExpression [as parseParenAndDistinguishExpression] (./node_modules/@babel/parser/src/parser/expression.ts:1798:12)\n' + ' at Parser.parseParenAndDistinguishExpression [as parseExprAtom] (./node_modules/@babel/parser/src/parser/expression.ts:1161:21)\n' + ' at Parser.parseExprAtom [as parseExprSubscripts] (./node_modules/@babel/parser/src/parser/expression.ts:721:23)\n' + ' at Parser.parseExprSubscripts [as parseUpdate] (./node_modules/@babel/parser/src/parser/expression.ts:698:21)\n' + ' at Parser.parseUpdate [as parseMaybeUnary] (./node_modules/@babel/parser/src/parser/expression.ts:660:23)\n' + ' at Parser.parseMaybeUnary [as parseMaybeUnaryOrPrivate] (./node_modules/@babel/parser/src/parser/expression.ts:398:14)\n' + ' at Parser.parseMaybeUnaryOrPrivate [as parseExprOps] (./node_modules/@babel/parser/src/parser/expression.ts:410:23)\n' + ' at Parser.parseExprOps [as parseMaybeConditional] (./node_modules/@babel/parser/src/parser/expression.ts:365:23)\n' + ' at Parser.parseMaybeConditional [as parseMaybeAssign] (./node_modules/@babel/parser/src/parser/expression.ts:305:21)\n' + ' at parseMaybeAssign (./node_modules/@babel/parser/src/parser/expression.ts:259:12)\n' + ' at Parser.callback [as allowInAnd] (./node_modules/@babel/parser/src/parser/expression.ts:3082:12)\n' + ' at Parser.allowInAnd [as parseMaybeAssignAllowIn] (./node_modules/@babel/parser/src/parser/expression.ts:258:17)\n' + ' at Parser.parseMaybeAssignAllowIn [as parseExprListItem] (./node_modules/@babel/parser/src/parser/expression.ts:2718:18)\n' + ' at Parser.parseExprListItem [as parseCallExpressionArguments] (./node_modules/@babel/parser/src/parser/expression.ts:1042:14)\n' + ' at Parser.parseCallExpressionArguments [as parseCoverCallAndAsyncArrowHead] (./node_modules/@babel/parser/src/parser/expression.ts:892:29)\n' + ' at Parser.parseCoverCallAndAsyncArrowHead [as parseSubscript] (./node_modules/@babel/parser/src/parser/expression.ts:781:19)\n' + ' at Parser.parseSubscript [as parseSubscripts] (./node_modules/@babel/parser/src/parser/expression.ts:742:19)\n' + ' at Parser.parseSubscripts [as parseExprSubscripts] (./node_modules/@babel/parser/src/parser/expression.ts:727:17)\n' + ' at Parser.parseExprSubscripts [as parseUpdate] (./node_modules/@babel/parser/src/parser/expression.ts:698:21)\n' + ' at Parser.parseUpdate [as parseMaybeUnary] (./node_modules/@babel/parser/src/parser/expression.ts:660:23)\n' + ' at Parser.parseMaybeUnary [as parseMaybeUnaryOrPrivate] (./node_modules/@babel/parser/src/parser/expression.ts:398:14)\n' + ' at Parser.parseMaybeUnaryOrPrivate [as parseExprOps] (./node_modules/@babel/parser/src/parser/expression.ts:410:23)\n' + ' at Parser.parseExprOps [as parseM'... 979 more characters, '2023-01-12T19:00:22.181Z workers [eao4q] Run 0 test(s), skipped 0 test(s)\n', '2023-01-12T19:00:22.182Z workers Jest Test Run Complete (eao4q): 2023-01-12T19:00:22.146Z\n', '2023-01-12T19:00:22.188Z workers [eao4q] Sandbox is responsive, closing it\n', '2023-01-12T19:00:22.193Z workers Failed to map the stack to user code, entry message: /angular-jest-wallaby-setup-sample-project/src/app/app.component.spec.ts: Missing initializer in const declaration. (14:17)\n' + '\n' + ' 12 |\n' + " 13 | it('should create the app', () => {\n" + '> 14 | const fixture: ComponentFixture = TestBed.createComponent(AppComponent);\n' + ' | ^\n' + ' 15 | const app: AppComponent = fixture.componentInstance;\n' + ' 16 | expect(app).toBeTruthy();\n' + ' 17 | });, stack: Jest encountered an unexpected token\n' + '\n' + 'Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.\n' + '\n' + 'Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.\n' + '\n' + 'By default "node_modules" folder is ignored by transformers.\n' + '\n' + "Here's what you can do:\n" + ' • If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/ecmascript-modules for how to enable it.\n' + ' • If you are trying to use TypeScript, see https://jestjs.io/docs/getting-started#using-typescript\n' + ' • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.\n' + ' • If you need a custom transformation specify a "transform" option in your config.\n' + ' • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.\n' + '\n' + "You'll find more details and exampl\n", '2023-01-12T19:00:22.195Z project Test run finished\n', '2023-01-12T19:00:22.196Z project Processed console.log entries\n', '2023-01-12T19:00:22.196Z project Processed loading sequences\n', '2023-01-12T19:00:22.196Z project Processed executed tests\n', '2023-01-12T19:00:22.196Z project Processed code coverage\n', '2023-01-12T19:00:22.207Z project Test run result processed and sent to IDE\n' ] } ```
smcenlly commented 1 year ago

Thanks for the sample repo.

Your project is using @angular-builders/jest@v15.0.0 which has a breaking change that Wallaby was not compatible with.

Please update to the latest version of Wallaby core, v1.0.1368 and delete your wallaby.js configuration file, it should work for you.


You can also update your Wallaby configuration file to explicitly use jest and it should also work for you:

wallaby.js

module.exports = () => {
  return {
    autoDetect: ['jest'],
    testFramework: {
      configFile: './jest.config.js'
    },
    trace: true
  }
};
node-ex commented 1 year ago

Now it is indeed working as expected, thank you for the update!