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

Please provide unit test example #224

Open
mraible opened this issue Apr 26, 2022 · 2 comments
Open

Please provide unit test example #224

mraible opened this issue Apr 26, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@mraible
Copy link

mraible commented Apr 26, 2022

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/okta-auth-js@6.4.3

$ 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

@kamilkazmierczakMtab
Copy link

Solution -> okta/samples-js-react#128 (comment)

@mraible
Copy link
Author

mraible commented Sep 5, 2022

You are correct @kamilkazmierczakMtab. This does indeed solve the problem.

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

No branches or pull requests

2 participants