Skip to content

polish(auth): Better readme for testing commands#18372

Merged
dschom merged 1 commit intomainfrom
better-auth-testing-readme
Feb 14, 2025
Merged

polish(auth): Better readme for testing commands#18372
dschom merged 1 commit intomainfrom
better-auth-testing-readme

Conversation

@dschom
Copy link
Copy Markdown
Contributor

@dschom dschom commented Feb 13, 2025

Because

  • Our readme with test instructions was very outdated

This pull request

  • Updates readme
  • Throws in modern examples

Issue that this pull request solves

Closes: # (issue number)

Checklist

Put an x in the boxes that apply

  • My commit is GPG signed.
  • If applicable, I have modified or added tests which pass locally.
  • I have added necessary documentation (if appropriate).
  • I have verified that my changes render correctly in RTL (if appropriate).

Screenshots (Optional)

Please attach the screenshots of the changes made in case of change in user interface.

Other information (Optional)

Any other information that is important to this pull request.

@dschom dschom requested a review from a team as a code owner February 13, 2025 20:47
Copy link
Copy Markdown
Contributor

@vpomerleau vpomerleau left a comment

Choose a reason for hiding this comment

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

Thanks for updating this documentation!

## Testing

Run tests with:
Before running tests make sure the correct services are running. If auth server is running in pm2 weird behavior can ensue, so
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
Before running tests make sure the correct services are running. If auth server is running in pm2 weird behavior can ensue, so
If auth server is running in pm2 weird behavior can ensue, so

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For unit-tests, we actually want none of the services to be running?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Unit tests do not need anything to be running. This is one of the main things that separates them from integration tests. If you look at our CI, unit tests can execute in total isolation. Now, should nothing be running at all? TBD… but it probably shouldn’t matter.

However, there's also this pre-existing comment in the readme that said “Note: stop the auth-server before running tests. Otherwise, they will fail with obscure errors.” This was written before we made a distinction between unit and integration tests... So not sure if it matters for unit-tests. I'd have to really vet this to be sure. I know for a fact a running auth-server messes with our test/remote tests.

Aside from quirks with auth server testing, in general, if you are working on unit tests I think it's good to not have ancillary things running. Do so and you might just be writing an integration test and not realizing it. That's why I think it's good practice to just run them after doing a yarn stop... ymmv.

NODE_ENV=dev npx mocha -r esbuild-register test/*/** -g "SQSReceiver"
```
- `yarn start infrastructure`
- `nx start fxa-customs-server`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe this would be a good spot to explain why customs is needed?

Copy link
Copy Markdown
Contributor Author

@dschom dschom Feb 13, 2025

Choose a reason for hiding this comment

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

I thought about this, but people can look at the code. And the reason may change overtime. Customs is an auxiliary service. I actually feel like customs deserves its own auth server specific section.


- Note: stop the auth-server before running tests. Otherwise, they will fail with obscure errors.
- You can use `LOG_LEVEL`, such as `LOG_LEVEL=debug` to specify the test logging level.
- For quick enviroment config, consider running tests with a .env file and the dotenv command. For example: `dotenv -- yarn workspace fxa-auth-server:test-integration remote`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we note more specifically which variables are required?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

He does mention below: recovery-phone tests require twilio testing credentials!

I think those might be the only ones?

Comment thread packages/fxa-auth-server/README.md Outdated
Copy link
Copy Markdown
Contributor

@LZoog LZoog left a comment

Choose a reason for hiding this comment

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

Thank you! This is so much clearer.

Comment thread packages/fxa-auth-server/README.md Outdated
_Note this matches how auth server unit tests jobs in CI._

To run a certain suite of tests (e.g. all remote tests):
For general development based testing, specific can be targeted using the test script or use mocha directly:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

specific [tests]?


- Note: stop the auth-server before running tests. Otherwise, they will fail with obscure errors.
- You can use `LOG_LEVEL`, such as `LOG_LEVEL=debug` to specify the test logging level.
- For quick enviroment config, consider running tests with a .env file and the dotenv command. For example: `dotenv -- yarn workspace fxa-auth-server:test-integration remote`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

He does mention below: recovery-phone tests require twilio testing credentials!

I think those might be the only ones?

@dschom dschom force-pushed the better-auth-testing-readme branch from 789cb02 to e351f00 Compare February 13, 2025 22:53
@dschom dschom merged commit ceaa834 into main Feb 14, 2025
@dschom dschom deleted the better-auth-testing-readme branch February 14, 2025 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants