facebook-atom / jest-electron-runner

custom test runner for Jest that allows tests to be run in Electron environment
MIT License
189 stars 33 forks source link

Jest-electron-runner hangs on simple test #53

Closed alex-klimov closed 4 years ago

alex-klimov commented 4 years ago

When using jest-electron-runner on a simple test: it starts running the test, launches electron process and then hangs without making a progress.

Removing jest-electron-runner makes the test run without issues.

Jest config:

module.exports = {
    "transform": {
        "^.+\\.tsx?$": "ts-jest"
    },
    "globals": {
        "ts-jest": {
            "tsConfig": "./tsconfig.json"
        }
    },
    "moduleFileExtensions": [
        "ts",
        "tsx",
        "js",
        "json",
        "node"
    ],
    "runner": "@jest-runner/electron/main",
    "testEnvironment": "node",
    "testMatch": ["**/test/**/*.(spec|test).ts"]
};

Test file:

describe("calculate", () => {
  it("add", () => {
    const result = 5 + 2;
    expect(result).toBe(7);
  });
});

Package.json dependencies versions:

{
    "devDependencies": {
        "@jest-runner/electron": "2.0.2",
        "@types/jest": "24.0.21",
        "@types/react": "16.9.11",
        "@types/react-dom": "16.9.3",
        "electron": "7.0.0",
        "fancy-log": "1.3.3",
        "gulp": "4.0.2",
        "gulp-changed": "4.0.2",
        "jest": "24.9.0",
        "ts-jest": "24.1.0",
        "tslint": "5.20.0",
        "typescript": "3.6.4"
    },
    "dependencies": {
        "react": "16.11.0",
        "react-dom": "16.11.0"
    }
}
alex-klimov commented 4 years ago

After debugging through the runner got the issue narrowed down to the problem in the latest release of Electron: https://github.com/electron/electron/issues/20931

Tests are running fine on electron version '5.0.11'. Closing the issue.