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

[Bug]: jest with angular not seeing setupFilesAfterEnv #195

Open
moczix opened this issue Nov 8, 2023 · 0 comments
Open

[Bug]: jest with angular not seeing setupFilesAfterEnv #195

moczix opened this issue Nov 8, 2023 · 0 comments
Labels
bug Something isn't working untriaged Requires traige

Comments

@moczix
Copy link

moczix commented Nov 8, 2023

What happened?

i tried to setup your bazel jest with angular but i have some issues,
this is repro repo: https://github.com/moczix/aspec-bazel-jest-repro

it look like the jest cant find configuration files for test.

there is angular module at path aspec-bazel-jest-repro/src/app/testowy-modul with simple test, when i run test with bazel, i got error

Executing tests from //src/app/testowy-modul:test
-----------------------------------------------------------------------------
�[31m�[31m�[1m�[1m● �[22m�[1mValidation Error�[22m:�[39m�[31m�[39m
�[31m�[31m�[39m�[31m�[39m
�[31m�[31m  Module �[1m./setup-jest.js�[22m in the �[1msetupFilesAfterEnv�[22m option was not found.�[39m�[31m�[39m
�[31m�[31m         �[1m<rootDir>�[22m is: /home/moczniak/.cache/bazel/_bazel_moczniak/58ab6779564054db7e12387a1a071d0a/sandbox/linux-sandbox/1045/execroot/bla/bazel-out/k8-fastbuild/bin/src/app/testowy-modul/test.sh.runfiles/bla/src/app/testowy-modul�[39m�[31m�[39m
�[31m�[31m�[39m�[31m�[39m
�[31m�[31m  �[1mConfiguration Documentation:�[22m�[39m�[31m�[39m
�[31m�[31m  https://jestjs.io/docs/configuration�[39m�[31m�[39m
�[31m�[31m�[39m�[31m�[39m

if i commend setupFilesAfterEnv in jest.config.js there is more errors, about tsconfig files.

When i read your js_library documentation, it says i should use copy_to_bin but it look like it copy files to root, not to the specific directory

Version

Development (host) and target OS/architectures:

Output of bazel --version:
bazel 5.3.2

Version of the Aspect rules, or other relevant rules from your
WORKSPACE or MODULE.bazel file:

workspace(
    name = "bla",
)
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "aspect_rules_js",
    sha256 = "dcd1567d4a93a8634ec0b888b371a60b93c18d980f77dace02eb176531a71fcf",
    strip_prefix = "rules_js-1.26.0",
    url = "https://github.com/aspect-build/rules_js/releases/download/v1.26.0/rules_js-v1.26.0.tar.gz",
)

load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")

rules_js_dependencies()

load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies", "register_jq_toolchains")

aspect_bazel_lib_dependencies()

register_jq_toolchains()

load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains")

v2_branch_head = "e5932f883443233f42b61d3fb87b2287518fbcba"

http_archive(
    name = "aspect_rules_ts",
    #sha256 = "ace5b609603d9b5b875d56c9c07182357c4ee495030f40dcefb10d443ba8c208",
    # ts_proto_library branch
    strip_prefix = "rules_ts-" + v2_branch_head,
    url = "https://github.com/aspect-build/rules_ts/archive/{}.tar.gz".format(v2_branch_head),
)

load("@aspect_rules_ts//ts:repositories.bzl", "rules_ts_dependencies")

# to get integrity run curl --silent https://registry.npmjs.org/typescript/5.2.2 | jq -r '.dist.integrity'
rules_ts_dependencies(
    ts_integrity = "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==",
    ts_version_from = "//:package.json",
)

 ## JEST START
http_archive(
    name = "aspect_rules_jest",
    sha256 = "098186ffc450f2a604843d8ba14217088a0e259ea6a03294af5360a7f1bcd3e8",
    strip_prefix = "rules_jest-0.19.5",
    url = "https://github.com/aspect-build/rules_jest/releases/download/v0.19.5/rules_jest-v0.19.5.tar.gz",
)

load("@aspect_rules_jest//jest:dependencies.bzl", "rules_jest_dependencies")

rules_jest_dependencies()

## JEST END


nodejs_register_toolchains(
    name = "nodejs",
    node_version = DEFAULT_NODE_VERSION,
)

load("@aspect_rules_js//npm:npm_import.bzl", "npm_translate_lock")

npm_translate_lock(
    name = "npm",
    bins = {
        "@angular/compiler-cli": {
            "ngcc": "./bundles/ngcc/main-ngcc.js",
        },
    },
    pnpm_lock = "//:pnpm-lock.yaml",
    npmrc = "//:.npmrc",
    verify_node_modules_ignored = "//:.bazelignore",
)

load("@npm//:repositories.bzl", "npm_repositories")

npm_repositories()

Language(s) and/or frameworks involved:
ANGULAR

How to reproduce

https://github.com/moczix/aspec-bazel-jest-repro

Any other information?

No response

@moczix moczix added the bug Something isn't working label Nov 8, 2023
@github-actions github-actions bot added the untriaged Requires traige label Nov 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working untriaged Requires traige
Projects
Status: No status
Development

No branches or pull requests

1 participant