Out of the box react-component project fails test execution with "TypeError: Object is not a constructor"
itzg opened this issue · comments
This issue is a:
- Bug report
This issue is reproducible with the repository
https://github.com/itzg/try-nwb-react-component
however, it contains completely out of the box content from nwb new react-component
other than the modified README.md
nwb is installed globally and the following transcript show how the npm run test
fails with no modifications on my part.
> npm version
{
npm: '7.12.0',
node: '16.1.0',
v8: '9.0.257.24-node.11',
uv: '1.41.0',
zlib: '1.2.11',
brotli: '1.0.9',
ares: '1.17.1',
modules: '93',
nghttp2: '1.42.0',
napi: '8',
llhttp: '6.0.1',
openssl: '1.1.1k+quic',
cldr: '39.0',
icu: '69.1',
tz: '2021a',
unicode: '13.0',
ngtcp2: '0.1.0-DEV',
nghttp3: '0.1.0-DEV'
}
> nwb version
v0.25.2
> nwb new react-component try-nwb-react-component
Creating a react-component project...
? Do you want to create an ES modules build for use by compatible bundlers? Yes
? Do you want to create a UMD build for global usage via <script> tag? No
create .gitignore
create .travis.yml
create CONTRIBUTING.md
create README.md
create demo\src\index.js
create nwb.config.js
create package.json
create src\index.js
create tests\.eslintrc
create tests\index.test.js
... REMOVED NPM ACTIVITY ...
> cd try-nwb-react-component
> npm run test
> try-nwb-react-component@1.0.0 test
> nwb test-react
START:
16 05 2021 10:01:49.363:INFO [karma-server]: Karma v5.0.9 server started at http://0.0.0.0:9876/
16 05 2021 10:01:49.366:INFO [launcher]: Launching browsers PhantomJS with concurrency unlimited
16 05 2021 10:01:49.437:INFO [launcher]: Starting browser PhantomJS
16 05 2021 10:01:59.800:INFO [PhantomJS 2.1.1 (Windows 8)]: Connected on socket k6ynVDimvC58zmVhAAAA with id 50452137
PhantomJS 2.1.1 (Windows 8) ERROR
TypeError: Object is not a constructor (evaluating 'getPolyfill()')
at webpack:///node_modules/reflect.getprototypeof/index.js:10:1 <- tests/index.test.js:35449:33
Finished in 0.459 secs / 0 secs @ 10:02:00 GMT-0500 (Central Daylight Time)
SUMMARY:
√ 0 tests completed
Karma exit code was 1
Added DEBUG=nwb
and now it fails in a different way prior to karma invocation:
> npm run test
> try-nwb-react-component@1.0.0 test
> nwb test-react
C:\Users\itzg\try-nwb-react-component\node_modules\debug\src\common.js:179
createDebug.names.push(new RegExp('^' + namespaces + '$'));
^
SyntaxError: Invalid regular expression: /^[default:$/: Unterminated character class
at new RegExp (<anonymous>)
at Function.enable (C:\Users\itzg\try-nwb-react-component\node_modules\debug\src\common.js:179:28)
at setup (C:\Users\itzg\try-nwb-react-component\node_modules\debug\src\common.js:261:14)
at Object.<anonymous> (C:\Users\itzg\try-nwb-react-component\node_modules\debug\src\node.js:236:37)
at Module._compile (node:internal/modules/cjs/loader:1109:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1138:10)
at Module.load (node:internal/modules/cjs/loader:989:32)
at Function.Module._load (node:internal/modules/cjs/loader:829:14)
at Module.require (node:internal/modules/cjs/loader:1013:19)
at require (node:internal/modules/cjs/helpers:93:18)
This might be a duplicate of #496 ; however, that issue has gone dormant and this current is easily reproducible.
I'm seeing a similar issue on Mac 11.15. NPM 7.7.6, Node 15.14.0. I've even tried downgrading to nwb@0.24.7 with these steps with the same issue:
$ npm install --global nwb@0.24.7
...
$ nwb --version
v0.24.7
$ nwb new react-component nwb-rc-0.24.7
(accept default settings)
$ cd nwb-rc-0.24.7
$ yarn
...
$ yarn test
yarn run v1.22.10
warning ../package.json: No license field
$ nwb test-react
START:
16 08 2021 13:30:25.090:INFO [karma-server]: Karma v4.4.1 server started at http://0.0.0.0:9876/
16 08 2021 13:30:25.092:INFO [launcher]: Launching browsers PhantomJS with concurrency unlimited
16 08 2021 13:30:25.118:INFO [launcher]: Starting browser PhantomJS
16 08 2021 13:30:26.536:INFO [PhantomJS 2.1.1 (Mac OS X 0.0.0)]: Connected on socket Bi_5BjhCWHKLs639AAAA with id 98992079
PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR
TypeError: Object is not a constructor (evaluating 'getPolyfill()')
at webpack:///node_modules/reflect.getprototypeof/index.js:10:1 <- tests/index.test.js:35482:33
Finished in 0.228 secs / 0 secs @ 13:39:34 GMT-0400 (Eastern Daylight Time)
SUMMARY:
✔ 0 tests completed
Karma exit code was 1
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
I found a project on github that completes its tests. It is using nwb 0.23.0.
git clone https://github.com/ucscXena/XenaGoWidget.git 2400727b6d5ec90b7a7a87703155c1cbe61c24a5
cd XenaGoWidget
npm install
npm run test
Blindly updating to 0.25.2 in package.json failed with a different, but seemingly related error:
√ XenaGoWidget % npm run test
> ucsc-xena-geneset@0.3.3-SNAPSHOT test
> NODE_OPTIONS=--max_old_space_size=4096 nwb test-react --timeout 20000
nwb config report for /Users/markeklund/play/XenaGoWidget/nwb.config.js
Error
✖ babel.runtime = 'polyfill'
Must be an Object (to configure transform-runtime options) or false (to disable use of the runtime-transform plugin)
I see there is a commit that changed from PhantomJS to ChromeHeadless. I tried changing the above to use it instead and got the same polyfill error. But when I reverted to 0.23.0, ChromeHeadless worked marvelously.
I see that the latest bleeding code has removed polyfill, so hopefully @insin is already has a fix for this in the next release.
I've gotten past the issue. It looks like a new release will help. This is what I did to accomplish it:
cd node_modules
rm -rf nwb
git clone https://github.com/insin/nwb.git
cd nwb
yarn
yarn build
chmod a+x ../.bin/nwb
cd ../..
yarn test