Skip to content

Commit

Permalink
update README with new how-to
Browse files Browse the repository at this point in the history
  • Loading branch information
borisno2 committed Sep 25, 2023
1 parent 8e1ae9f commit 3c22fb3
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions examples/testing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@ You can also access a GraphQL Playground at [localhost:3000/api/graphql](http://

## Features

Keystone provides a testing library in [`@keystone-6/core/testing`](https://keystonejs.com/guides/testing) which helps you write tests using [Jest](https://jestjs.io/).
This example project uses this library to add tests to the [`withAuth()`](../with-auth) example project. The tests can be found in [example.test.ts](./example.test.ts)

### Running tests

The project's `package.json` includes a script:

```
"test": "jest"
"test": "node --loader tsx example-test.ts"
```

We can run the tests by running the command
Expand All @@ -38,16 +37,17 @@ pnpm test
which should give output ending with:

```
PASS ./example.test.ts
✓ Create a Person using the Query API (183 ms)
✓ Check that trying to create user with no name (required field) fails (116 ms)
✓ Check access control by running updateTask as a specific user via context.withSession() (198 ms)
Test Suites: 1 passed, 1 total
Tests: 3 passed, 3 total
Snapshots: 0 total
Time: 2.316 s, estimated 5 s
Ran all test suites.
✔ Create a User using the Query API (139.404167ms)
✔ Check that trying to create user with no name (required field) fails (96.580875ms)
✔ Check access control by running updateTask as a specific user via context.withSession() (193.86275ms)
ℹ tests 3
ℹ suites 0
ℹ pass 3
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 0.072292
```

## Try it out in CodeSandbox 🧪
Expand Down

0 comments on commit 3c22fb3

Please sign in to comment.