Skip to content

Commit

Permalink
Merge pull request #5 from devagrawal09/main
Browse files Browse the repository at this point in the history
Updated package versions and added instructions for test user credentials
  • Loading branch information
colinclerk authored Jul 3, 2023
2 parents 1f4c8f0 + a2c9ddc commit 237a2e3
Show file tree
Hide file tree
Showing 8 changed files with 1,319 additions and 4,271 deletions.
2 changes: 2 additions & 0 deletions .env.local.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=your_clerk_publishable_key
CLERK_SECRET_KEY=your_clerk_secret_key
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts

# cypress
cypress.env.json
28 changes: 15 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,29 @@ https://clerk.dev/docs/testing/cypress

## Getting Started

1. add a .env.local file with your keys:
```
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_**************
CLERK_SECRET_KEY=sk_test_**************
```
2. Install deps
```bash
npm install
```
1. Sign up for a Clerk account at https://clerk.dev.
2. Go to Clerk's dashboard and create an application.
3. Set the required Clerk environment variables as shown in the [example env file](./env.local.sample).
4. `npm install` the required dependencies.
5. `npm run dev` to launch the development server.

## Testing

1. Create a test account using [Clerk Dashboard](https://dashboard.clerk.com) or by signing up on the application.
2. Copy the `cypress.env.example.json` file to `cypress.env.json`.

3. Run the development server:
```bash
npm run dev
cp cypress.env.example.json cypress.env.json
```
Open [http://localhost:3000](http://localhost:3000) with your browser to make sure the application is working.

3. Set `test_email` and `test_password` to the credentials of the test account.
4. Open Cypress while keeps the development server running:

```bash
npm run cypress:open
```

5. Navigate through cypress and run the tests

e2e testing -> chrome -> start e2e testing in chrome

**If you are running NOT running on `localhost:3000`**, you will need to update the `baseUrl` in `cypress.config.js` to match your development server's URL.
4 changes: 4 additions & 0 deletions cypress.env.sample.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"test_email": "your_clerk_test_email",
"test_password": "your_clerk_test_password"
}
2 changes: 1 addition & 1 deletion cypress/e2e/clerk-example.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe("Signed out", () => {

describe("Signed in", () => {
beforeEach(() => {
cy.session('signed-in', () => {
cy.session("signed-in", () => {
cy.signIn();
});
});
Expand Down
4 changes: 2 additions & 2 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ Cypress.Commands.add(`signIn`, () => {
.then(async (window) => {
await cy.clearCookies({ domain: window.location.domain });
const res = await window.Clerk.client.signIn.create({
identifier: "[email protected]",
password: "clerkpassword1234",
identifier: Cypress.env(`test_email`),
password: Cypress.env(`test_password`),
});

await window.Clerk.setActive({
Expand Down
Loading

0 comments on commit 237a2e3

Please sign in to comment.