Skip to content

Commit

Permalink
docs: run e2e in headless mode
Browse files Browse the repository at this point in the history
  • Loading branch information
homura committed Apr 6, 2023
1 parent 168811c commit dc77237
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions e2e/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# E2E

## Quick Start

```sh
HEADLESS=true npm run test -w @nexus-wallet/e2e
```

## Add a New Case

Cases are located in [tests](./tests) directory. We have provided an example
Expand Down Expand Up @@ -32,3 +38,26 @@ describe('Some scenario', () => {
});
});
```

The `DefaultTestEnv.setup` will inject a `ckb` and `testEnv` object to the global scope, and also create a new wallet for EACH test case.
If you want to use one wallet in multiple test cases, you can use `new DefaultTestEnv` to instead of `DefaultTestEnv.setup`

```ts
describe('Some scenario', () => {
it('should do something', async () => {
const testEnv = new DefaultTestEnv();
const ckb = testEnv.getInjectedCkb();
await ckb.request({ method: 'some_method' });

testEnv.dispose();
});

it('should do something else', async () => {
const testEnv = new DefaultTestEnv();
const ckb = testEnv.getInjectedCkb();
await ckb.request({ method: 'some_method' });

testEnv.dispose();
});
});
```

0 comments on commit dc77237

Please sign in to comment.