Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/assert-equals/dappdriver
🕹️ DappDriver is an e2e testing framework designed for testing decentralized applications (dApps) using MetaMask, Rainbow or Zerion
https://github.com/assert-equals/dappdriver
automation browser chrome dapp dapp-developers e2e ethereum extension metamask playwright rainbow selenium testing webdriver zerion
Last synced: about 8 hours ago
JSON representation
🕹️ DappDriver is an e2e testing framework designed for testing decentralized applications (dApps) using MetaMask, Rainbow or Zerion
- Host: GitHub
- URL: https://github.com/assert-equals/dappdriver
- Owner: assert-equals
- License: mit
- Created: 2024-03-02T15:35:37.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-11-06T00:24:30.000Z (13 days ago)
- Last Synced: 2024-11-18T19:01:14.763Z (about 9 hours ago)
- Topics: automation, browser, chrome, dapp, dapp-developers, e2e, ethereum, extension, metamask, playwright, rainbow, selenium, testing, webdriver, zerion
- Language: TypeScript
- Homepage: https://assert-equals.github.io/DappDriver/
- Size: 2.7 MB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
DappDriver
Automated tests for dApps[DappDriver](https://github.com/assert-equals/dappdriver) is a web testing framework designed for testing decentralized applications (dApps).
It's all about being flexible and user-friendly, DappDriver seamlessly integrates both [Playwright](https://playwright.dev/) and [Selenium WebDriver](https://www.selenium.dev/).
DappDriver loads [MetaMask](https://metamask.io/), [Rainbow](https://rainbow.me/) or [Zerion](https://zerion.io/) into the browser session, empowering you to efficiently confirm blockchain transactions.
Read on to get started locally in a couple of minutes.
> [!NOTE]
> DappDriver is in active development, so all APIs are subject to change.## Install
DappDriver is [available on npm](https://www.npmjs.com/package/@assert-equals/dappdriver):
```shell
yarn add @assert-equals/dappdriver
```## Get Started
**Download a Wallet**
First, install MetaMask, Rainbow or Zerion:
```shell
npx dappdriver -w metamask
```Installing Rainbow:
DappDriver requires a personal access token to call Github’s API over HTTPS to download Rainbow from GitHub's artifact repository. You can configure the token through the `GITHUB_TOKEN` environment variable:
```shell
GITHUB_TOKEN=token npx dappdriver -w rainbow
```**Add a Page Object**
Then, write your page object in `test/page/dapp.ts`:
```ts
import { HTMLElement, PageObject } from '@assert-equals/dappdriver';
import { Connect } from '@assert-equals/dappdriver/wallet';export class Dapp extends PageObject {
private accountsLabel: () => HTMLElement = () => new HTMLElement('#accounts');
private connectButton: () => HTMLElement = () => new HTMLElement('#connectButton');
constructor() {
super('https://metamask.github.io/', 'E2E Test Dapp');
}async getAccounts(): Promise {
return await this.accountsLabel().getText();
}async connect(): Promise {
return await this.connectButton().clickAndOpensInWindow(Connect);
}
}
```**Write Your First Test**
Next, write your test in `test/spec/dapp.spec.ts`:
```ts
import { CHROME, DappDriver, METAMASK, PLAYWRIGHT, BrowserOptions } from '@assert-equals/dappdriver';
import { Connect } from '@assert-equals/dappdriver/wallet';
import { expect } from 'chai';
import { Dapp } from '../page/dapp';describe('E2E Test Dapp', () => {
let dapp: Dapp;
const browserOptions: BrowserOptions = {
extension: {
wallet: METAMASK,
seed: 'phrase upgrade clock rough situate wedding elder clever doctor stamp excess tent'
}
};beforeEach(async () => {
dapp = await DappDriver.create(
'https://metamask.github.io/test-dapp/',
PLAYWRIGHT,
CHROME,
Dapp,
browserOptions
);
});afterEach(async () => {
await DappDriver.dispose();
});it('connects Account One to the dapp', async () => {
const connectPopup: Connect = await dapp.connect();
dapp = await connectPopup.accept(Dapp);
const actualAccount: string = await dapp.getAccounts();
const expectedAccount: string = '0xe18035bf8712672935fdb4e5e431b1a0183d2dfc';
expect(actualAccount).to.be.equal(expectedAccount);
});
});
```**Run the Test**
Finally, run your tests:
```shell
yarn test
```## Documentation
Read our [API documentation](https://assert-equals.github.io/DappDriver/).
## Support
Join our [community](https://github.com/assert-equals/DappDriver/discussions) and elevate your decentralized testing experience.
If you like DappDriver, [give us a star ⭐ on GitHub!](https://github.com/assert-equals/DappDriver)