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

1.6.2 tests don't start (project create with nwb) #77

Closed
jonenst opened this issue Sep 8, 2021 · 6 comments
Closed

1.6.2 tests don't start (project create with nwb) #77

jonenst opened this issue Sep 8, 2021 · 6 comments

Comments

@jonenst
Copy link

jonenst commented Sep 8, 2021

Hi, I created a react project using nwb. After upgrading is-equal from 1.6.1 to 1.6.2, my tests now fail without running anything with:

> nwb test-react


START:
08 09 2021 16:07:59.760:INFO [karma-server]: Karma v5.0.9 server started at http://0.0.0.0:9876/
08 09 2021 16:07:59.762:INFO [launcher]: Launching browsers ChromeHeadless with concurrency unlimited
08 09 2021 16:07:59.765:INFO [launcher]: Starting browser ChromeHeadless
08 09 2021 16:08:01.159:INFO [Chrome Headless 93.0.4577.0 (Linux x86_64)]: Connected on socket IQeKSGKrg5KIMm-WAAAA with id 21371944
Chrome Headless 93.0.4577.0 (Linux x86_64) ERROR
  Uncaught TypeError: getPolyfill is not a function
  at webpack:///node_modules/reflect.getprototypeof/index.js:10:1 <- src/components/TopBar/TopBar.test.js:115258:22
  
  TypeError: getPolyfill is not a function
      at Object../node_modules/reflect.getprototypeof/index.js (webpack:///node_modules/reflect.getprototypeof/index.js:10:1 <- src/components/TopBar/TopBar.test.js:115258:22)
      at __webpack_require__ (webpack:///webpack/bootstrap:19:1 <- src/components/TopBar/TopBar.test.js:20:30)
      at Object../node_modules/object.getprototypeof/implementation.js (webpack:///node_modules/object.getprototypeof/implementation.js:5:1 <- src/components/TopBar/TopBar.test.js:64550:29)
      at __webpack_require__ (webpack:///webpack/bootstrap:19:1 <- src/components/TopBar/TopBar.test.js:20:30)
      at Module../node_modules/object.getprototypeof/implementation.mjs (webpack:///node_modules/object.getprototypeof/implementation.mjs:1:1 <- src/components/TopBar/TopBar.test.js:64569:76)
      at __webpack_require__ (webpack:///webpack/bootstrap:19:1 <- src/components/TopBar/TopBar.test.js:20:30)
      at Object../node_modules/object.getprototypeof/polyfill.js (webpack:///node_modules/object.getprototypeof/polyfill.js:4:1 <- src/components/TopBar/TopBar.test.js:64592:22)
      at __webpack_require__ (webpack:///webpack/bootstrap:19:1 <- src/components/TopBar/TopBar.test.js:20:30)
      at Module../node_modules/object.getprototypeof/polyfill.mjs (webpack:///node_modules/object.getprototypeof/polyfill.mjs:1:1 <- src/components/TopBar/TopBar.test.js:64635:70)
      at __webpack_require__ (webpack:///webpack/bootstrap:19:1 <- src/components/TopBar/TopBar.test.js:20:30)

Finished in 0.639 secs / 0 secs @ 16:08:01 GMT+0200 (heure d’été d’Europe centrale)

SUMMARY:
✔ 0 tests completed
Karma exit code was 1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR!  test: `nwb test-react`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the  test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/harperjon/.npm/_logs/2021-09-08T14_08_01_961Z-debug.log

reverting to 1.6.1 works for me, but I would like to keep my dependencies up to date. Do you have any idea of what might be happening ? Looking at the given lines in node modules, when I add a console.log to what getPolyfill is, I get:
node_modules/reflect.getprototypeof/index.js

var getPolyfill = require('./polyfill');
+ console.log(getPolyfill);
Chrome Headless 93.0.4577.0 (Linux x86_64) LOG: Object{then: function then(resolve) { ... }, default: function getPolyfill() { ... }}

Not sure what to do from there.

Thanks in advance.

@ljharb
Copy link
Member

ljharb commented Sep 8, 2021

Requiring a CJS module should never produce a thenable; somehow it seems like it’s loading the ESM version instead, but it shouldn’t be. (note this seems to be an issue with reflect.getprototypeof, not with is-equal directly)

Im not familiar with nwb, what is it?

@ljharb
Copy link
Member

ljharb commented Sep 8, 2021

Are you perhaps letting webpack transpile things in node_modules? If so, a) that's best avoided, and b) it's doing it wrong.

@jonenst
Copy link
Author

jonenst commented Sep 8, 2021

Hi, thank you for your time. nwb is this project: https://github.com/insin/nwb . It generates an npm project with a complete build system. I use it to make react libraries because create-react-app doesn't allow to build libraries easily.

Unfortunately, I used nwb because I don't have enough knowledge to setup a robust build system myself, so I can't answer your questions :( and it seems like nwb is not as robust as I would like it to be.

You can reproduce my issue if you are interested. I used:

$ sudo npm install -g  --unsafe-perm nwb
[...]
+ nwb@0.25.2

$ nwb new react-app tuu
Creating a react-app project...
  create .gitignore
  create .travis.yml
  create CONTRIBUTING.md
  create README.md
  create nwb.config.js
  create package.json
  create public/.gitkeep
  create src/App.css
  create src/App.js
  create src/index.css
  create src/index.html
  create src/index.js
  create src/react.svg
  create tests/.eslintrc
  create tests/App.test.js
✔ Installing react and react-dom
✔ Initing Git repo
$ cd tuu/
# it seems like nwb already initialize a node_modules, so don't need to install.
# but you can rm -rf it and npm install and it fails in the same way.
$ npm run test
> tuu@1.0.0 test /tmp/bar/tuu
> nwb test-react


START:
08 09 2021 17:36:46.891:INFO [karma-server]: Karma v5.0.9 server started at http://0.0.0.0:9876/
08 09 2021 17:36:46.892:INFO [launcher]: Launching browsers PhantomJS with concurrency unlimited
08 09 2021 17:36:46.916:INFO [launcher]: Starting browser PhantomJS
08 09 2021 17:36:47.127:INFO [PhantomJS 2.1.1 (Linux x86_64)]: Connected on socket GChCaIIaxtzq9rV4AAAA with id 41645376
PhantomJS 2.1.1 (Linux x86_64) ERROR
  TypeError: Object is not a function (evaluating 'getPolyfill()')
  at webpack:///usr/local/lib/node_modules/nwb/node_modules/reflect.getprototypeof/index.js:10:1 <- tests/App.test.js:6830:33

Finished in 0.218 secs / 0 secs @ 17:36:47 GMT+0200 (heure d’été d’Europe centrale)

SUMMARY:
✔ 0 tests completed
Karma exit code was 1

If you think this is not a problem with your project and are not interested, feel free to close the issue.

thanks again

@ljharb
Copy link
Member

ljharb commented Sep 8, 2021

You're not supposed to build libraries :-) that's the library author's job.

I believe v1.0.1 of reflect.getprototypeof may address the issue by removing the ESM files entirely (something i needed to do anyways). Can you update all your deps and confirm?

@jonenst
Copy link
Author

jonenst commented Sep 8, 2021

I, I confirm that reflect.getprototypeof v1.0.1 fixes the problem. Thanks ! Now generating a new nwb project and running the tests work out of the box.

@ljharb
Copy link
Member

ljharb commented Sep 8, 2021

There's definitely still an underlying bug in nwb; you may want to file it and clarify which versions of reflect.getprototypeof trigger it, but I'll close this as resolved.

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

No branches or pull requests

2 participants