Skip to content

Flaky testcase in CLI on GH Actions #2861

@gerteck

Description

@gerteck

Please confirm that you have searched existing issues in the repo

Yes, I have searched the existing issues

Any related issues?

These changes are in line with #2831

Tell us about your environment

GH Actions

MarkBind version

v6.3.1

Describe the bug and the steps to reproduce it

markbind-cli:  PASS  test/unit/ipUtil.test.ts
@markbind/vue-components: Cleared C:\Users\runneradmin\AppData\Local\Temp\jest
markbind-cli:  FAIL  test/unit/cliUtil.test.ts
markbind-cli:   ● Test suite failed to run
markbind-cli:     jest: failed to cache transform results in: C:/Users/runneradmin/AppData/Local/Temp/jest/jest-transform-cache-5dd76c68f00da1210af64d35428b28a4-79ef2876fae7ca75eedb2aa53dc48338/42/cliUtil_422f3b1058728e3037880f9dad527280
markbind-cli:     Failure message: ENOENT: no such file or directory, open 'C:\Users\runneradmin\AppData\Local\Temp\jest\jest-transform-cache-5dd76c68f00da1210af64d35428b28a4-79ef2876fae7ca75eedb2aa53dc48338\42\cliUtil_422f3b1058728e3037880f9dad527280.1882365808'
markbind-cli:       3 |
markbind-cli:       4 | import path from 'path';
markbind-cli:     > 5 | import * as cliUtil from '../../src/util/cliUtil.js';
markbind-cli:         | ^
markbind-cli:       6 |
markbind-cli:       7 | jest.mock('fs');
markbind-cli:       8 | jest.mock('process');
markbind-cli:       at writeFileSync (../../node_modules/write-file-atomic/lib/index.js:216:13)
markbind-cli:       at writeCacheFile (../../node_modules/@jest/transform/build/ScriptTransformer.js:908:33)
markbind-cli:       at writeCodeCacheFile (../../node_modules/@jest/transform/build/ScriptTransformer.js:875:3)
markbind-cli:       at ScriptTransformer._buildTransformResult (../../node_modules/@jest/transform/build/ScriptTransformer.js:514:5)
markbind-cli:       at ScriptTransformer.transformSource (../../node_modules/@jest/transform/build/ScriptTransformer.js:554:17)
markbind-cli:       at ScriptTransformer._transformAndBuildScript (../../node_modules/@jest/transform/build/ScriptTransformer.js:674:40)
markbind-cli:       at ScriptTransformer.transform (../../node_modules/@jest/transform/build/ScriptTransformer.js:726:19)
markbind-cli:       at Object.require (test/unit/cliUtil.test.ts:5:1)
markbind-cli: Test Suites: 1 failed, 1 passed, 2 total
markbind-cli: Tests:       9 passed, 9 total
markbind-cli: Snapshots:   0 total
markbind-cli: Time:        3.676 s
markbind-cli: Ran all test suites.
markbind-cli: Error: ENOENT: no such file or directory, open 'C:\Users\runneradmin\AppData\Local\Temp\jest\perf-cache-5dd76c68f00da1210af64d35428b28a4-da39a3ee5e6b4b0d3255bfef95601890'
markbind-cli:     at Object.writeFileSync (node:fs:2437:20)
markbind-cli:     at D:\a\markbind\markbind\node_modules\@jest\test-sequencer\build\index.js:275:12
markbind-cli:     at Map.forEach (<anonymous>)
markbind-cli:     at TestSequencer.cacheResults (D:\a\markbind\markbind\node_modules\@jest\test-sequencer\build\index.js:274:17)
markbind-cli:     at runJest (D:\a\markbind\markbind\node_modules\@jest\core\build\runJest.js:370:13)
markbind-cli:     at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
markbind-cli:     at async _run10000 (D:\a\markbind\markbind\node_modules\@jest\core\build\cli\index.js:343:7)
markbind-cli:     at async runCLI (D:\a\markbind\markbind\node_modules\@jest\core\build\cli\index.js:198:3)
markbind-cli:     at async Object.run (D:\a\markbind\markbind\node_modules\jest-cli\build\run.js:130:37)
markbind-cli: npm error Lifecycle script `test` failed with error:
markbind-cli: npm error code 1
markbind-cli: npm error path D:\a\markbind\markbind\packages\cli
markbind-cli: npm error workspace markbind-cli@6.3.1
markbind-cli: npm error location D:\a\markbind\markbind\packages\cli
markbind-cli: npm error command failed
markbind-cli: npm error command C:\Windows\system32\cmd.exe /d /s /c jest --colors && cd test/functional && node ../../dist/test/functional/test.js

flaky cli test as above for WIndows runner, rerunning gets:

markbind-cli: jest-haste-map: Haste module naming collision: markbind-cli
markbind-cli:   The following files share their name; please adjust your hasteImpl:
markbind-cli:     * <rootDir>\package.json
markbind-cli:     * <rootDir>\dist\package.json
markbind-cli:  PASS  test/unit/ipUtil.test.ts (5.309 s)
markbind-cli:  PASS  test/unit/cliUtil.test.ts (6.814 s)

Although there is no functional change.

Expected behavior

Tests are not flaky, erodes test confidence.

Additionally, there might be some flaky testcases in core as well due to site generation that I previously added, it might be worth to investigate further.

Anything else?

Quick investigation suggests something like:

The Jest transformation cache error on Windows is likely caused by global mocking of the process and fs modules in cliUtil.test.ts. Mocking process globally replaces the entire global process object, which can break Jest's internal operations (like file path resolution and platform detection) that are needed for caching transformed files. This is especially flaky on Windows because path handling and file locking are more sensitive to environment changes.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions