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

Jest tests failing/hanging when styled-components plugin is enabled #32

Closed
nickskotny opened this issue May 9, 2022 · 7 comments
Closed

Comments

@nickskotny
Copy link

nickskotny commented May 9, 2022

With the styled-components plugin enabled and using @swc-jest, I'm seeing my tests hang in our CI pipeline. The failures seem inconsistent, sometimes with no output, sometimes they will just hang until the pipeline times out. WIthout the plugin enabled, tests pass as expected.

I updated all of our snapshots which seem to appropriately add the displayName.

These are the only types of output I was able to get from any of the runs while running jest with the --coverage flag in CI.

Test suite failed to run
    failed to handle: range end index 12150176 out of range for slice of length 532448

    Stack backtrace:
       0: <unknown>
       1: <unknown>
       2: _ZN6v8impl12_GLOBAL__N_123FunctionCallbackWrapper6InvokeERKN2v820FunctionCallbackInfoINS2_5ValueEEE
       3: _ZN2v88internal12_GLOBAL__N_119HandleApiCallHelperILb0EEENS0_11MaybeHandleINS0_6ObjectEEEPNS0_7IsolateENS0_6HandleINS0_10HeapObjectEEESA_NS8_INS0_20FunctionTemplateInfoEEENS8_IS4_EENS0_16BuiltinArgumentsE
       4: _ZN2v88internal21Builtin_HandleApiCallEiPmPNS0_7IsolateE
      at Compiler.transformSync (../../../node_modules/@swc/core/index.js:137:25)
      at transformSync (../../../node_modules/@swc/core/index.js:217:21)
      at Object.process (../../../node_modules/@swc/jest/index.js:55:45)
      at ScriptTransformer.transformSource (../../../node_modules/@jest/transform/build/ScriptTransformer.js:619:31)
      at ScriptTransformer._transformAndBuildScript (../../../node_modules/@jest/transform/build/ScriptTransformer.js:765:40)
      at ScriptTransformer.transform (../../../node_modules/@jest/transform/build/ScriptTransformer.js:822:19)
thread '<unnamed>' panicked at 'range end index 12150176 out of range for slice of length 7811040', library/core/src/slice/index.rs:72:5
stack backtrace:

.swcrc

{
  "jsc": {
    "parser": {
      "syntax": "typescript",
      "jsx": true,
      "tsx": true,
      "dynamicImport": false,
      "privateMethod": false,
      "functionBind": false,
      "exportDefaultFrom": false,
      "exportNamespaceFrom": false,
      "decorators": false,
      "decoratorsBeforeExport": false,
      "topLevelAwait": false,
      "importMeta": false
    },
    "experimental": {
      "plugins": [["@swc/plugin-styled-components", { "displayName": true }]]
    },
    "transform": null,
    "target": "es2015",
    "loose": false,
    "externalHelpers": false,
    "keepClassNames": false
  }
}

swc/dependency versions:

  "@swc/cli": "0.1.57",
  "@swc/core": "1.2.172",
  "@swc/jest": "0.2.20",
  "@swc/plugin-styled-components": "0.7.0",

Any thoughts on how/why this behavior could be tied to the styled-components plugin?

@kdy1
Copy link
Member

kdy1 commented May 9, 2022

cc @kwonoj

@kwonoj
Copy link
Member

kwonoj commented May 9, 2022

Do we have small repro? Need to dig if plugin itself have issues or host have problems.

@nickskotny
Copy link
Author

So far I've only been running into this in our CI environment when the plugin is enabled, not locally. So unfortunately don't have a quick way to reproduce this. Is there any other info I could provide that would be helpful?

@kwonoj
Copy link
Member

kwonoj commented May 9, 2022

So this is not 100% reproducible as well as we don't have local repro?

Unfortunately that'll make investigation exceptionally difficult.

@kwonoj
Copy link
Member

kwonoj commented Jun 19, 2022

Can we confirm if this is same? #42 (comment)

@SimonGodefroid
Copy link

I have a similar case with this error, I'm using swc + craco + styled-components plugin. The tests run fine on whichever test does not render a component (e.g. unit tests on helpers) but as soon as it reaches a test that renders a component containing some styled-components. Now I can't tell whether it's the template literals that cause the issue or the import.

    TypeError: _macro.css is not a function

      1 | import styled, { css } from 'styled-components/macro';
      2 |
    > 3 | const activeLink = css`

@kdy1
Copy link
Member

kdy1 commented Jan 30, 2024

Closing as not actionable as there's not enough information to reproduce

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants