Skip to content
This repository was archived by the owner on Jan 16, 2025. It is now read-only.
This repository was archived by the owner on Jan 16, 2025. It is now read-only.

Compile typescript from child_process fork does not work (dynamic import) #169

@javeoff

Description

@javeoff

I have typescript fork(filename) from node:child_process. When i try to run tests, I have an error Unknown file extension ".ts" for /[...myfullpath]/getSpots.ts. All imports works good but import file via fork for multithreading

jest.config.ts

import type { Config } from '@jest/types';

const config: Config.InitialOptions = {
  extensionsToTreatAsEsm: ['.ts'],
  testEnvironment: 'node',
  transform: {
    '.*\\.(tsx?)$': ['@swc/jest', {
      jsc: {
        target: "es2021",
        parser: {
          "syntax": "typescript",
          "decorators": true,
          "dynamicImport": true
        },
      },
    }],
  },
  testRegex: [
    '/tests/.*\\.(test|spec)\\.(ts)$',
    '/src/.*\\.(test|spec)\\.(ts)$',
  ],
  transformIgnorePatterns: [
    'node_modules',
    './dist',
  ],
  testPathIgnorePatterns: ['./dist'],
  moduleFileExtensions: ['ts', 'js', 'json', 'node'],
  testTimeout: 240 * 1_000,
};

export default config;


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions