chaijs / chai

BDD / TDD assertion framework for node.js and the browser that can be paired with any testing framework.
https://chaijs.github.io
MIT License
8.11k stars 694 forks source link

Tests failed to load after upgrading to 5.1.1 #1626

Closed mike-4040 closed 2 months ago

mike-4040 commented 2 months ago

Environment

  1. Node 20.11.1

  2. Dependencies

    "chai": "^5.1.1",
    "mocha": "^10.4.0",
    "ts-node": "^10.9.2",
    "typescript": "^5.4.5",
  3. Tests configuration

    • .mocharc file
      # .mocharc
      {
      "$schema": "https://json.schemastore.org/mocharc",
      "reporter": "spec",
      "require": ["ts-node/register", "src/testUtils/global-mocha-fixture.ts"],
      }
    • test file
      
      # ./src/sample.test.ts
      import { expect } from 'chai';

describe('Simple Test', () => { it('should return true', () => { expect(true).to.be.true; }); });


- running test `npx ./node_modules/mocha/bin/mocha.js ./src/sample.test.ts`

##  Issue
After upgrading chai 4.4.1 => 5.1.1 consistently getting Error:

Exception during run: TypeError: Unknown file extension ".ts" for ./src/sample.test.ts at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:160:9) at defaultGetFormat (node:internal/modules/esm/get_format:203:36) at defaultLoad (node:internal/modules/esm/load:143:22) at async ModuleLoader.load (node:internal/modules/esm/loader:409:7) at async ModuleLoader.moduleProvider (node:internal/modules/esm/loader:291:45) at async link (node:internal/modules/esm/module_job:76:21) { code: 'ERR_UNKNOWN_FILE_EXTENSION' }