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

test(client): initial Jest + RTL setup #1992

Merged
merged 22 commits into from
Jun 1, 2021
Merged

test(client): initial Jest + RTL setup #1992

merged 22 commits into from
Jun 1, 2021

Conversation

ubbe-xyz
Copy link
Collaborator

@ubbe-xyz ubbe-xyz commented May 13, 2021

Reasoning 💡

This PR adds the initial unit/integration test setup with Jest + RTL + MSW.

As a proof of concept, we have covered the existing acceptance criteria for signIn() and getSession from the client module: next-auth/client. The tests have been written in a fashion that mimics how users of this library will use these functions in the context o a React application.

Screenshot 2021-05-27 at 15 38 21

Screenshot 2021-05-27 at 15 35 03

I have also the tests to the CI, have a look at the workflow (I feel we need to clean the actions soon) 🤔

...

Checklist 🧢

  • Documentation
  • Tests
  • Ready to be merged

Affected issues 🎟

Fixes #1937

@vercel
Copy link

vercel bot commented May 13, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/nextauthjs/next-auth/6F6GnaMgbRJspdiytvqSeZZkpcAY
✅ Preview: https://next-auth-git-test-client-module-nextauthjs.vercel.app

@ubbe-xyz ubbe-xyz requested review from balazsorban44, iaincollins and ndom91 and removed request for balazsorban44 May 13, 2021 18:03
@github-actions github-actions bot added client Client related code core Refers to `@auth/core` labels May 13, 2021
@ubbe-xyz ubbe-xyz requested a review from balazsorban44 May 13, 2021 18:03
@ubbe-xyz ubbe-xyz marked this pull request as ready for review May 13, 2021 18:03
@balazsorban44 balazsorban44 mentioned this pull request May 13, 2021
Copy link
Member

@ndom91 ndom91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! LGTM 👍

I've always wanted to try out msw!

@vercel vercel bot temporarily deployed to Preview May 14, 2021 21:46 Inactive
@ndom91
Copy link
Member

ndom91 commented May 15, 2021

Whats up with lots of these actions failing? They seem to be throwing errors about the package-lock not matching. Shouldn't they atleast be passing with the one basic test jest test you'd added Iluia?

I was about to push mine, but I see we're still using the npm6 i.e. lockfileVersion: 1, so I couldn't as I only have npm7 available.

@lluia can you push your package-lock.json at some point as well? Thanks!

@vercel vercel bot temporarily deployed to Preview May 20, 2021 07:59 Inactive
@vercel vercel bot temporarily deployed to Preview May 20, 2021 12:22 Inactive
@vercel vercel bot temporarily deployed to Preview May 20, 2021 12:25 Inactive
@ubbe-xyz
Copy link
Collaborator Author

@ndom91 I regenerated the 🔒 file, and the CI seems happy now 😁

@ndom91
Copy link
Member

ndom91 commented May 20, 2021

@lluia Alright awesome! Good work!!

I'm so happy that tests for this anddd the adapters are slowly but surely coming together 🍻🚀

@vercel vercel bot temporarily deployed to Preview May 20, 2021 17:31 Inactive
@vercel vercel bot temporarily deployed to Preview May 20, 2021 17:36 Inactive
@vercel vercel bot temporarily deployed to Preview May 26, 2021 15:02 Inactive
@vercel vercel bot temporarily deployed to Preview May 28, 2021 09:09 Inactive
@vercel vercel bot temporarily deployed to Preview May 28, 2021 16:26 Inactive
@vercel vercel bot temporarily deployed to Preview May 30, 2021 18:14 Inactive
@ndom91 ndom91 self-requested a review May 30, 2021 19:47
package.json Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
Copy link
Collaborator Author

@ubbe-xyz ubbe-xyz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few comments 💭

package.json Outdated Show resolved Hide resolved
src/client/__tests__/mocks.js Outdated Show resolved Hide resolved
@vercel vercel bot temporarily deployed to Preview May 30, 2021 20:02 Inactive
@vercel vercel bot temporarily deployed to Preview May 30, 2021 21:03 Inactive
@vercel vercel bot temporarily deployed to Preview June 1, 2021 07:03 Inactive
@vercel vercel bot temporarily deployed to Preview June 1, 2021 12:43 Inactive
@ubbe-xyz ubbe-xyz requested a review from balazsorban44 June 1, 2021 12:43
@vercel vercel bot temporarily deployed to Preview June 1, 2021 12:44 Inactive
Copy link
Member

@ndom91 ndom91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@vercel vercel bot temporarily deployed to Preview June 1, 2021 15:09 Inactive
@ubbe-xyz ubbe-xyz merged commit e8a9e8a into main Jun 1, 2021
@ubbe-xyz ubbe-xyz deleted the test/client-module branch June 1, 2021 15:12
@ajaykarthikr ajaykarthikr mentioned this pull request Jun 10, 2021
5 tasks
mnphpexpert added a commit to mnphpexpert/next-auth that referenced this pull request Sep 2, 2024
…s#1992)

* test(client): initial Jest + RTL setup

* test(client): add tests for `getSession`

* test(client): document expect cases and fix regex

* test(client): small refactors

* chore(npm): re-generate package-lock.json

* test(client): initial test for `signIn`

* test(client): refactor session tests for consistency

* test(client): credentials/email signin scenarios

* test(client): finish sign-in tests

* chore(github): add test to ci

* test(client): refactor and extend use cases

* test(client): sign-out tests

* refactor(client): code review suggestions (1)

* test(client): add few more sign-in/sign-out cases

* test(client): broadcasting session events

* fix(client): handle fetch providers error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client Client related code core Refers to `@auth/core`
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add tests 🧪
3 participants