Skip to content

[bug] ESM imports cause errors #3181

Closed
Closed
@thiagodp

Description

@thiagodp

What are you trying to achieve?

Use EcmaScript Modules (ESM) imports in test files. Example:

import { something } from '../src/something.js`

Feature( 'Example' );
// ...

What do you get instead?

import { something } from '../src/something.js`
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at wrapSafe (internal/modules/cjs/loader.js:979:16)
    at Module._compile (internal/modules/cjs/loader.js:1027:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at ${APP}\node_modules\mocha\lib\mocha.js:390:36
    at Array.forEach (<anonymous>)
    at Mocha.loadFiles (${APP}\node_modules\mocha\lib\mocha.js:387:14)

Cannot use import statement outside a module

Details

  • CodeceptJS version: 3.2.2
  • NodeJS Version: 1415.1
  • Operating System: Windows 10
  • Configuration file: Same problem with configurations files created with npx codeceptjs init for any UI Helper,

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