hello. I am trying to start unit testing with the ...
# sdf
m
hello. I am trying to start unit testing with the suitecloud unit testing and jest. I am following the documentation at https://www.npmjs.com/package/@oracle/suitecloud-unit-testing I can run a test with the sample-test.js file but then it says to create the jest.config.js file and I try to run the sample test and I start getting the below error first test is without the jest.config and second that fails is with it
Copy code
mberns@Matthews-MacBook-Pro premier-digital  % npm test

> asset-prefix-rename@1.0.0 test
> jest

 PASS  __tests__/sample-test.js
  Basic jest test with simple assert
    ✓ should assert stings are equal

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        0.149 s
Ran all test suites.
mberns@Matthews-MacBook-Pro premier-digital  % npm test

> asset-prefix-rename@1.0.0 test
> jest

 FAIL  __tests__/sample-test.js
  ● Test suite failed to run

    TypeError: Cannot destructure property 'config' of 'cacheKeyOptions' as it is undefined.

      at Object.getCacheKey (node_modules/babel-jest/build/index.js:217:14)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        0.18 s, estimated 1 s
Ran all test suites.
jest.config.js file
Copy code
const SuiteCloudJestConfiguration = require("@oracle/suitecloud-unit-testing/jest-configuration/SuiteCloudJestConfiguration");

module.exports = SuiteCloudJestConfiguration.build({
    projectFolder: 'src',
    projectType: SuiteCloudJestConfiguration.ProjectType.ACP,
});
sample-test.js file
Copy code
describe('Basic jest test with simple assert', () => {
    it('should assert stings are equal', () => {
        const a = 'foobar';
        const b = 'foobar';
        expect(a).toMatch(b);
    });
});
Project structure attached as image
a
Why are you creating jest.config.js?
Your main configuration should be in suitecloud.config.js
m
Is there other documentation? The npm docs say to use the jest.config
d
in your
package.json
, what version of
jest
do you have? (basically I was seeing that same error when upgrading my packages & jest to v27, try downgrading jest to v26 - this resolved for me)