Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SyntaxError: Cannot use import statement outside a module #10070

Closed
pavel-butkevich-98 opened this issue May 21, 2020 · 2 comments
Closed

SyntaxError: Cannot use import statement outside a module #10070

pavel-butkevich-98 opened this issue May 21, 2020 · 2 comments

Comments

@pavel-butkevich-98
Copy link

pavel-butkevich-98 commented May 21, 2020

Hi! Trying to add customSequencer:

import type { Test } from 'jest-runner';
const Sequencer = require('@jest/test-sequencer').default;

class CustomSequencer extends Sequencer {
  sort(tests: Test[]) {
    const orderPath = [
      './../tests/webhooks/authentication.spec.ts',
      './../tests/webhooks/notify-booking-change.spec.ts',
    ];
    return tests.sort((testA, testB) => (testA.path > testB.path ? 1 : -1));
}

export default CustomSequencer;

But, Have an error when run jest command:
image

My depencencies:

"dependencies": {
    "@hqoapp/functional-vertical-sdk": "0.0.60",
    "@jest/reporters": "25.2.4",
    "@jest/test-result": "25.2.4",
    "@jest/test-sequencer": "26.0.1",
    "@types/body-parser": "1.19.0",
    "@types/express": "4.17.3",
    "@types/jest": "25.1.4",
    "@types/lodash": "4.14.149",
    "@types/node": "13.9.5",
    "@types/node-ipc": "9.1.2",
    "@types/uuid": "3.4.4",
    "aws-sdk": "2.650.0",
    "axios": "0.19.2",
    "body-parser": "1.19.0",
    "chalk": "4.0.0",
    "class-transformer": "0.2.3",
    "class-validator": "0.11.1",
    "dotenv": "8.2.0",
    "express": "4.17.1",
    "jest": "25.2.4",
    "jest-runner": "26.0.1",
    "lodash": "4.17.15",
    "node-ipc": "9.1.1",
    "reflect-metadata": "0.1.13",
    "start-server-and-test": "1.10.11",
    "ts-jest": "25.3.0",
    "ts-node": "8.8.1",
    "typescript": "3.8.3",
    "uuid": "3.3.2"
  }
@SimenB
Copy link
Member

SimenB commented May 21, 2020

We don't transpile test sequencers, you need to make sure they are CJS.

A PR adding support for transpiling it is welcome, see #8810

@SimenB SimenB closed this as completed May 21, 2020
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants