Skip to content

Jest Example fails on Windows聽#1454

Description

@zjkipping

馃悶 bug report

Affected Rule

jest_test

Is this a regression?

no

Description

The jest_test rule fails on windows with the following error:

Error: Can't find a root directory while resolving a config file path.
Provided path to resolve: ./jest.config.js

馃敩 Minimal Reproduction

https://github.com/bazelbuild/rules_nodejs/tree/master/examples/jest

running bazel test ...

馃敟 Exception or Error

see above in explanation

馃實 Your Environment

Operating System:

Windows 10

Output of bazel version:

  
Bazelisk version: v1.1.0
Build label: 1.2.1
Build target: bazel-out/x64_windows-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Tue Nov 26 15:24:17 2019 (1574781857)
Build timestamp: 1574781857
Build timestamp as int: 1574781857
  

Rules version (SHA):

  
a54b2511d6dae42c1f7cdaeb08144ee2808193a088004fc3b464a04583d5aa2e
  

Activity

  1. alexeagle commented on Dec 20, 2019

    @alexeagle
    Collaborator

    I suspect you need to copy jest.config.js to the output folder and then reference that copy.

    See https://github.com/bazelbuild/rules_nodejs/blob/master/docs/Built-ins.md#copy_to_bin

  2. Socolin commented on May 14, 2020

    @Socolin

    Hello

    I got the same error, on windows trying to run jest tests.

    So I tried to add copy_to_bin as you suggested @alexeagle but after some digging I found that jest is executed in C:\users\$USER\_bazel_$USER\u3lrkeg4\execroot\<workspace-name>\bazel-out\x64_windows-fastbuild\bin\test.bat.runfiles\<workspace-name> which is empty.

    The directory C:\users\$USER\_bazel_$USER\u3lrkeg4\execroot\<workspace-name>\bazel-out\x64_windows-fastbuild\bin\ seems well populated.

    I found in the source, there is a comment about Windows

    https://github.com/bazelbuild/rules_nodejs/blob/master/examples/jest/BUILD.bazel#L14

    So I tried to add this argument and ran bazel test test --enable_runfiles. Then I get another error

    INFO: Invocation ID: edecd830-ef9a-4fca-adc0-a20e5c3f1b25
    INFO: Analyzed target //:test (503 packages loaded, 10582 targets configured).
    INFO: Found 1 test target...
    INFO: Deleting stale sandbox base C:/users/$USER/_bazel_$USER/olmlednd/sandbox
    FAIL: //:test (see C:/users/$USER/_bazel_$USER/olmlednd/execroot/examples_jest/bazel-out/x64_windows-fastbuild/testlogs/test/test.log)
    INFO: From Testing //:test:
    ==================== Test output for //:test:
    ERROR: Manifest file C:\Users\$USER\_bazel_$USER\olmlednd\execroot\examples_jest\bazel-out\x64_windows-fastbuild\bin\test.bat.runfiles\examples_jest\test.bat.runfiles_manifest does not exist.
    ================================================================================
    Target //:test up-to-date:
      dist/bin/test.sh
      dist/bin/test_loader.js
      dist/bin/test_require_patch.js
      dist/bin/test.bat
    INFO: Elapsed time: 7.752s, Critical Path: 0.45s
    INFO: 2 processes: 1 remote cache hit, 1 local.
    INFO: Build completed, 1 test FAILED, 3 total actions
    

    Do you have any hint, about what could go wrong ?

  3. lukasholzer commented on Sep 4, 2020

    @lukasholzer
    Collaborator

    @alexeagle When I go the folder examples/jest in the rules_nodejs (stable branch) and running bazel run :test it is working fine on macOS and Linux but on windows, it is failing with:

    image

    I think I found somehow the issue:

    If I run bazel run //:test it will fail with the above error

    If I rerun bazel run //:test --enable_runfiles with the enable_runfiles flag It will fail differently with:

    ERROR: Manifest file c:\Users\ADMINI~1\_BAZEL~1\rgyky3dz\execroot\EXAMPL~1\bazel-out\x64_windows-fastbuild\bin\test.bat.runfiles\examples_jest\test.bat.runfiles_manifest does not exist.
    

    And When I run now the first command without the runfiles flag it will pass bazel run //:test

    image

    After a bazel clean The first issue with Can't find a root directory while resolving a config file path. occurs again.

  4. lukasholzer commented on Sep 4, 2020

    @lukasholzer
    Collaborator

    Addition:

    When I run it with verbose logs you can see that in the failing case it uses the module_mappings.json from a different location. This is the only difference I can see with --define=VERBOSE_LOGS=1

    Failing:

    [link_node_modules.js] manifest file C:/users/administrator/_bazel_administrator/rgyky3dz/execroot/examples_jest/bazel-out/x64_windows-fastbuild/bin/_test.module_mappings.json

    Passing

    [link_node_modules.js] manifest file c:/users/admini~1/_bazel~1/rgyky3dz/execroot/exampl~1/bazel-out/x64_windows-fastbuild/bin/test.bat.runfiles/examples_jest/_test.module_mappings.json

  5. added a commit that references this issue on Sep 8, 2020
    0589311
  6. added a commit that references this issue on Sep 17, 2020
    a090e56
  7. github-actions commented on Nov 6, 2020

    @github-actions
    Contributor

    This issue has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs in two weeks. Collaborators can add a "cleanup" or "need: discussion" label to keep it open indefinitely. Thanks for your contributions to rules_nodejs!

  8. added
    Can Close?We will close this in 30 days if there is no further activity
    on Nov 6, 2020
  9. added 3 commits that reference this issue on Nov 10, 2020
    2463136
    cf80b0b
    1e785bc
  10. github-actions commented on Nov 20, 2020

    @github-actions
    Contributor

    This issue was automatically closed because it went two weeks without a reply since it was labeled "Can Close?"

  11. added 4 commits that reference this issue on Nov 23, 2020
    979137d
    23cc9bd
    73aa64e
    c70ed1d
  12. added a commit that references this issue on Nov 27, 2020
    daa884d
  13. added 2 commits that reference this issue on Nov 27, 2020
    b3c012a
    20c259a
  14. added 2 commits that reference this issue on Nov 27, 2020
    cc04f6c
    3ffefa1
  15. added a commit that references this issue on Jan 15, 2021
    9671291
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Can Close?We will close this in 30 days if there is no further activity

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions