-
Notifications
You must be signed in to change notification settings - Fork 4
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
Issue in combination with Storybook and Cypress #1
Comments
It appears that Cypress doesn't play with ESM well (!16467). There are some workarounds described there, but fur such a simple package as this one it is no problem to expose a CJS module. I published 1.1.0 with this feature. You should be able to import it using the CJS syntax too: const sort = require('storybook-multilevel-sort') Requesting the exports by the name of the NPM module ('storybook-multilevel-sort') will choose automatically between 'storybook-multilevel-sort/lib/index.js' (ESM) and 'storybook-multilevel-sort/lib/index.cjs' (CJS). Does it work in your project? |
Not yet, this is the error message at the moment
|
What is the value of I tried it in both CJS and ESM modules and it is always a function.
|
So, I console logged on the browser the same file content, meaning the Via node_modules
and this approach does not work, and it gives the error I posted above Via script in the project folder
and this approach works |
Might help choosing CJS or ESM in Cypress. (#1) Also use teru to execute the tests.
## [1.1.2](v1.1.1...v1.1.2) (2022-11-27) ### Bug Fixes * Declare exports in package.json ([c36cafc](c36cafc)), closes [#1](#1)
I added one more way to declare CJS/ESM exports in "exports": {
"require": "./lib/index.cjs",
"import": "./lib/index.js"
}, It might help, but I'm not sure. Alternatively, you could try addressing the exported files directly instead of just by the package name, for example, CJS: const sort = require('storybook-multilevel-sort/lib/index.cjs') and ESM: import sort from 'storybook-multilevel-sort/lib/index.js' |
with the version |
Hello, I'm using this library in a Storybook project. The library is imported as described in the README and it works as expected.
At the same time, there are Cypress tests running against the Storybook website. Since the
storybook-multilevel-sort
library is used Cypress tests are failing.Cypress dashboard opens regularly, once a test is selected to be run, effect is that
No tests found. Cypress could not detect tests in this file.
and the output in the Cypress window is the followingI was thinking to use babel in cypress plugin configuration, but this makes no sense since the code with the import lives in Storybook files and not in Cypress files or tests files.
It is not super clear what to try to babelify in the process, since Cypress tests are independent by Storybook, or maybe I'm not seeing something obvious?
Thanks for the support
The text was updated successfully, but these errors were encountered: