okta-react icon indicating copy to clipboard operation
okta-react copied to clipboard

Please provide unit test example

Open mraible opened this issue 2 years ago • 2 comments

Describe the feature request?

It would be awesome if we could provide a unit test example in this repository, or in the the official React samples repo. There is an App.test.jsx in the hosted-login example, but there's no way to run it.

$ npm test
npm ERR! Missing script: "test"

This issue is motivated by a switch to Vite I made in the Okta CLI's React sample. npm test works fine with Auth JS 6.1.0, but if I update to 6.4.3, it fails.

$ npm i @okta/[email protected]

$ npm test
 FAIL  src/App.test.jsx
  ✕ renders title link (120 ms)

  ● renders title link

    No useable method found in ["native","idb","localstorage"]

      at node_modules/@okta/okta-auth-js/dist/webpack:/OktaAuth/node_modules/broadcast-channel/dist/esbrowser/method-chooser.js:42:25
      at new he (node_modules/@okta/okta-auth-js/dist/webpack:/OktaAuth/node_modules/broadcast-channel/dist/esbrowser/broadcast-channel.js:22:17)
      at e.value (node_modules/@okta/okta-auth-js/dist/webpack:/OktaAuth/lib/ServiceManager.ts:136:24)
      at e.startElector (node_modules/@okta/okta-auth-js/dist/webpack:/OktaAuth/lib/ServiceManager.ts:100:12)
      at e.start (node_modules/@okta/okta-auth-js/dist/webpack:/OktaAuth/lib/OktaAuth.ts:366:25)
      at node_modules/@okta/src/Security.tsx:83:4
      at invokePassiveEffectCreate (node_modules/react-dom/cjs/react-dom.development.js:23487:20)
      at HTMLUnknownElement.callCallback (node_modules/react-dom/cjs/react-dom.development.js:3945:14)
      at HTMLUnknownElement.callTheUserObjectsOperation (node_modules/jsdom/lib/jsdom/living/generated/EventListener.js:26:30)
      at innerInvokeEventListeners (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:340:25)
      at invokeEventListeners (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:276:3)
      at HTMLUnknownElementImpl._dispatch (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:223:9)
      at HTMLUnknownElementImpl.dispatchEvent (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:94:17)
      at HTMLUnknownElement.dispatchEvent (node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js:241:34)
      at Object.invokeGuardedCallbackDev (node_modules/react-dom/cjs/react-dom.development.js:3994:16)
      at invokeGuardedCallback (node_modules/react-dom/cjs/react-dom.development.js:4056:31)
      at flushPassiveEffectsImpl (node_modules/react-dom/cjs/react-dom.development.js:23574:9)
      at unstable_runWithPriority (node_modules/scheduler/cjs/scheduler.development.js:468:12)
      at runWithPriority$1 (node_modules/react-dom/cjs/react-dom.development.js:11276:10)
      at flushPassiveEffects (node_modules/react-dom/cjs/react-dom.development.js:23447:14)
      at Object.<anonymous>.flushWork (node_modules/react-dom/cjs/react-dom-test-utils.development.js:992:10)
      at flushWorkAndMicroTasks (node_modules/react-dom/cjs/react-dom-test-utils.development.js:1001:5)
      at node_modules/react-dom/cjs/react-dom-test-utils.development.js:1080:11

Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total

New or Affected Resource(s)

Developers all over the world.

Provide a documentation link

No response

Additional Information?

No response

mraible avatar Apr 26 '22 18:04 mraible