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 Test in Create-React-App broken #215
Comments
unit tests work find for commits in master and local, see "yarn test" in: I think this error is from an older version "tabulator_tables_1.default is not a constructor", upgrade react-tabulator to the lastest version should fix it. |
With the current release, I can still reproduce on another machine:
CI aside, can't you reproduce on your machine? |
Yes, there is some issue when it runs in local, sometimes it fails to launch puppeteer and got stuck there. You may want to kill node processes and try to run the unit tests again. |
Here we are, half a year later and with react-tabulator version 0.15.0, and I still see this issue, while writing Jest tests. Since half of my app depends on (react-)tabulator, I'm pretty much lost when it comes to writing tests for that part. Is there any progress happening meanwhile? Or is a workaround available? Since I also had trouble with monaco-editor, I tried to apply the same trick, first to tabulator-tables then to react-tabulator: "transformIgnorePatterns": [
"/node_modules/(?!monaco-editor)/",
"/node_modules/(?!react-tabulator)/"
],
"moduleNameMapper": {
"^monaco-editor$": "monaco-editor/esm/vs/editor/editor.api",
"^react-tabulator$": "react-tabulator/lib/index.js",
} but that didn't help. Note: react-tabulator works without trouble in the application (many thanks for that, btw.!), just not in Jest tests. |
Sorry about this intermittent puppeteer launching issue in local. |
I'm pretty sure the issue I have is related to this and #204 so rather than write a new bug report, I'll just add my thoughts here. I've been looking at adding a iOS app to our desktop webapp using the Meteor Cordova framework which essentially runs in a webview served over a local web server and I was seeing an error like Looking in the network tab in devtools I discovered that the only difference was in the way the But why was it loading different modules? To answer that question you have to understand that Meteor builds 2 separate bundles, one for modern web browsers called So I tried forcing Cordova to use the ESM module by cloning the Next I looked at why this error was occurring in the first place. Turns out, after much hair pulling that there's a bunch of interoperability issues with ESM and CJS modules. The solution? TypeScript has the
Tested this out by running the repro in this issue and npm linking to a React-tabulator 0.15.0 rebuild:
|
I've created a npm fork @timiscoding/react-tabulator if anyone wants to test the fix. But ideally, you'll probably want to use patch-package so you don't have to update all your imports in the code base. As you can see from the diff, the timiscoding@0decbd2#diff-e6427b57cc4fd1d3909cd8ff56371e8a4e23b90dc66ab1995abb37d1990c076aR98 |
react-tabulator eg. admin/forms/list won't show list items. see ngduc/react-tabulator#215
@timiscoding Thanks for working this out! I'd prefer, however, that @ngduc takes this in to the original react-tabulator node module. Would make things easier on my end. In any case, I'm happy to see there's a solution. |
@mike-lischke Of course, the best way would be to update the original package. Hoping to get confirmation that it indeed fixes it for others. |
@timiscoding - I downloaded your fork today to see if it fixed the issues we were having with React unit tests failing. Indeed it did! Would be GREAT if this was incorporated into an update in the original package. Thank you for addressing the issue. |
@timiscoding I also found the time finally to test your fork and also for me it worked. Many thanks! However, I see a problem with mounting the underlying tabulator table in my I don't know if that's a specific problem of your fork or something that @ngduc should look at. Is it possible to "force" mounting the underlying tabulator when the |
@mike-lischke Good to hear it! Are you using react-test-renderer? Refs don’t work because it doesn’t mimic a full dom environment. So you have to mock the refs using ‘create NodeMock’ api https://reactjs.org/docs/test-renderer.html#ideas The only change I made in the fork was in the build step so apart from that, the code would be functionally identical to 0.15.0 |
Thanks for the hint. Yes, I'm using react-test-render but also enzyme, where I can Doesn't belong to the discussion here, however. I hope your changes will be taken over to the main repo sooner than later. Have a good time! |
I haven’t used enzyme in a while but could be related to incompatible adapters? |
The |
* tim-survey-builder: (26 commits) add readme Question types render own Inspector properties. Update parts atom to include type config. Enable importing absolute paths. Restructure folders. Recoil devtools. Mobile navbar views. Move items with animation. Dnd lock axis. Improve mobile responsive for frame + single type. Refactor DND to avoid unneeded part rerenders. Short answer integration Start adding mobile responsiveness. Fix recoil not working in ios. Fix storybook startup issue due to new Framework imports. Fix ios bug where any component using react-tabulator eg. admin/forms/list won't show list items. see ngduc/react-tabulator#215 Add ios build Add dragndrop for canvas Reinstalling storybook Load editor's json into builder. Builder can update editor source on clicking save. Update DND. Update placeholder type. Enable builder in editor without blowing up. Fix circular imports. Refactor recoil state. Load json and save source. Fix error in engine.js when using strict mode. Add toolbar to generate source. Refactor to make it easier to add new question types. Update single item styles Reduce storybook startup time. Update dnd for single items. Fix recoil + rbd bug github/facebookexperimental/Recoil#496 Fix styled-components bug github/styled-components/styled-components#3564 Merge in Minh's short question code. Add dnd to single items. EditProperty can auto render with complex paths Modify single items in canvas and inspector ...
@timiscoding is it safe to use your package? |
The only change is adding a ts compiler option in the build script and running it. I haven't used the original package since my last comment so I'd try the latest release to see if it has already fixed this issue. |
Title
TypeError: tabulator_tables_1.default is not a constructor
Environment Details
Long Description
To reproduce:
npx create-react-app test_tabulator --template typescript
cd test_tabulator
npm i react-tabulator
npm test
Result:
Expected Result: No Warnings
Test can even be made to fail by making it async:
yielding the test result:
Unfortunately, the test works in Codesandbox (https://codesandbox.io/s/vr3in).
Workaround
No idea right now.
Related Issue
#204
I tried
npm cache clean --force
, followed by deletingnode_modules
andnpm install
, butnpm test
still gives the same FAIL.The text was updated successfully, but these errors were encountered: