Experience Builder Developer Edition: Tests fail to run

296
0
07-14-2021 05:01 PM
Labels (2)
RYANCARL
New Contributor III

Hello all,

Not sure if there is a GitHub repo that I can submit an issue to, but I have noticed that in the 1.4 release of the ArcGIS Experience Builder Developer Edition the command npm run test will fail with the error:

 

 

 

 

my-pc ~/Desktop/ArcGISExperienceBuilder/client
$ npm run test
> exb-client@1.4.0 test C:\Users\user\Desktop\ArcGISExperienceBuilder\client
> jest --runInBand
 FAIL  your-extensions/widgets/simple/tests/simple-widget.test.tsx
  ● Test suite failed to run
    TypeError: global.systemRegister is not a function
      at SystemJS.Object.<anonymous>.System.register (dist/jimu-core/react.js:18:16)
      at Object.<anonymous> (dist/jimu-core/react.js:26:12)
      at Object.<anonymous> (node_modules/@wojtekmaj/enzyme-adapter-react-17/src/ReactSeventeenAdapter.js:2:1)
      at Object.<anonymous> (node_modules/@wojtekmaj/enzyme-adapter-react-17/src/index.js:2:18)
      at Object.<anonymous> (jimu-for-test/setup-jest.js:3:17)
Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        11.737 s
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! exb-client@1.4.0 test: `jest --runInBand`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the exb-client@1.4.0 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!     C:\Users\user\AppData\Roaming\npm-cache\_logs\2021-07-14T23_39_11_102Z-debug.log

 

 

 

 


After looking around the community board it looks like someone noticed this issue a little while ago and mentions the fix here .

It seems like the fix for this is to adjust the client/jimu-for-test/setup-jest.js like the following code:

 

 

 

 

// require('jest-fetch-mock').enableMocks()
// const Enzyme = require('enzyme');
// const Adapter = require('@wojtekmaj/enzyme-adapter-react-17')
// const { System } = require('systemjs');
// Enzyme.configure({ adapter: new Adapter() });
// global.systemRegister = System.register;
require('jest-fetch-mock').enableMocks()
const { System } = require('systemjs');
global.systemRegister = System.register;
const Enzyme = require('enzyme');
const Adapter = require('@wojtekmaj/enzyme-adapter-react-17')
Enzyme.configure({ adapter: new Adapter() });

 

 

 

 

The commented out code is the code that is originally in the file and the code that is bellow is the adjustment to make tests work.

How has everyone been testing their code?

0 Replies