Skip to content

Commit 63a3e39

Browse files
committed
first commit
0 parents  commit 63a3e39

39 files changed

+703
-0
lines changed

.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# MetaMask test seed https://github.com/MetaMask/metamask-extension/blob/v12.6.0/test/e2e/seeder/ganache.ts
2+
DAPPDRIVER_SEED_PHRASE="phrase upgrade clock rough situate wedding elder clever doctor stamp excess tent"

.github/workflows/test.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Tests
2+
on:
3+
push:
4+
branches: [main]
5+
pull_request:
6+
branches: [main]
7+
8+
jobs:
9+
test:
10+
timeout-minutes: 10
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: actions/setup-node@v4
15+
with:
16+
node-version: 20
17+
- name: Install Dependencies
18+
run: npm install
19+
- name: Build Code
20+
run: npm run build
21+
- name: Install Playwright Browser
22+
run: npx playwright install chrome
23+
- name: Install Browser Extension
24+
run: npm run setup
25+
- name: Run All Tests
26+
run: xvfb-run npm test

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
package-lock.json
3+
.vscode
4+
.DS_Store

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Assert Equals
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# DappDriver examples
2+
3+
A set of examples to help demonstrate using [DappDriver](https://github.com/assert-equals/DappDriver).
4+
5+
## Examples
6+
7+
- [Cucumber](./packages/cucumber)
8+
- [Jest](./packages/jest)
9+
- [Mocha](./packages/mocha/)
10+
11+
## Getting Started
12+
13+
Install Dependancies
14+
15+
```
16+
npm install
17+
```
18+
19+
Build Code
20+
21+
```
22+
npm run build
23+
```
24+
25+
Install Playwright Browser
26+
27+
```
28+
npx playwright install chrome
29+
```
30+
31+
Install Browser Extension
32+
33+
```
34+
npm run setup
35+
```
36+
37+
Run All Tests
38+
39+
```
40+
npm test
41+
```

package.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"name": "@assert-equals/dappdriver-examples",
3+
"version": "1.0.0",
4+
"description": "A set of examples to help demonstrate using DappDriver",
5+
"keywords": [
6+
"cucumber",
7+
"dappdriver",
8+
"jest",
9+
"mocha",
10+
"playwright",
11+
"rainbow",
12+
"selenium",
13+
"webdriver",
14+
"zerion"
15+
],
16+
"scripts": {
17+
"build": "npm run build -ws --if-present",
18+
"clean": "rm -rf node_modules package-lock.json && npm run clean -ws",
19+
"setup": "npm run setup -ws --if-present",
20+
"test": "npm test -ws --if-present"
21+
},
22+
"private": "true",
23+
"workspaces": [
24+
"packages/*"
25+
],
26+
"license": "MIT"
27+
}

packages/cucumber/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

packages/cucumber/README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Cucumber
2+
3+
An example to help demonstrate using DappDriver and [Cucumber](https://github.com/cucumber/cucumber-js) to test a sample dapp
4+
5+
## Getting Started
6+
7+
Install Dependancies
8+
9+
```
10+
npm install
11+
```
12+
13+
Build Code
14+
15+
```
16+
npm run build
17+
```
18+
19+
Install Playwright Browser
20+
21+
```
22+
npx playwright install chrome
23+
```
24+
25+
Install Browser Extension
26+
27+
```
28+
npm run setup
29+
```
30+
31+
Run All Tests
32+
33+
```
34+
npm test
35+
```

packages/cucumber/cucumber.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"default": {
3+
"requireModule": ["ts-node/register"],
4+
"require": ["features/**/*.ts"]
5+
}
6+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { Dapp } from "@assert-equals/dappdriver-examples-page-objects";
2+
import { Connect } from "@assert-equals/dappdriver/wallet";
3+
import { When, Then } from "@cucumber/cucumber";
4+
import { expect } from "chai";
5+
6+
When("the user connects their wallet", async (): Promise<void> => {
7+
let dapp: Dapp = new Dapp();
8+
const connectPage: Connect = await dapp.connect();
9+
dapp = await connectPage.accept<Dapp>(Dapp);
10+
await dapp.waitForWindows(1);
11+
});
12+
13+
Then(
14+
"the dapp displays the users wallet {string}",
15+
async (expectedAccount: string): Promise<void> => {
16+
const dapp: Dapp = new Dapp();
17+
const actualAccount: string = await dapp.getAccounts();
18+
expect(actualAccount).to.be.equal(expectedAccount);
19+
}
20+
);

0 commit comments

Comments
 (0)