Skip to content

Instantly share code, notes, and snippets.

View maxhoheiser's full-sized avatar

Max maxhoheiser

View GitHub Profile
@maxhoheiser
maxhoheiser / package.json
Last active March 17, 2022 16:02
Synpress package.json example
{
"devDependencies": {
"@synthetixio/synpress": "^1.1.1",
"@testing-library/cypress": "^8.0.2",
"cypress": "^9.5.1",
"eslint-plugin-cypress": "^2.12.1",
"eslint-plugin-testing-library": "^5.0.6"
},
"name": "my-dApp",
"version": "1.0.0",
@maxhoheiser
maxhoheiser / synpress.json
Created March 16, 2022 10:45
Example synpress config file
{
"baseUrl": "http://localhost:3000",
"userAgent": "synpress",
"retries": { "runMode": 0, "openMode": 0 },
"integrationFolder": "integration",
"screenshotsFolder": "screenshots",
"videosFolder": "videos",
"video": true,
"chromeWebSecurity": true,
"viewportWidth": 1366,
@maxhoheiser
maxhoheiser / .eslintrc.js
Created March 16, 2022 10:53
Synpress example eslint config file
const path = require('path');
const synpressPath = path.join(
process.cwd(),
'/node_modules/@synthetixio/synpress',
);
module.exports = {
extends: `${synpressPath}/.eslintrc.js`,
};
@maxhoheiser
maxhoheiser / tsconfig.json
Created March 16, 2022 12:28
Example tsconfig.json for Synpress
{
"compilerOptions": {
"allowJs": true,
"baseUrl": "../../node_modules",
"types": [
"cypress",
"@types/puppeteer-core",
"@synthetixio/synpress/support",
"cypress-wait-until",
"@testing-library/cypress"
@maxhoheiser
maxhoheiser / command.js
Last active March 17, 2022 15:42
Example commands.js file for Synpress
import "@testing-library/cypress/add-commands";
Cypress.Commands.add("login", () => {
cy.visit("/");
cy.get("[data-cy=metamaskButton]").then((button) => {
const acceptAllAccount = true;
if (button.text() === "Connect Wallet") {
button.trigger("click");
cy.acceptMetamaskAccess(acceptAllAccount).then((connected) => {
expect(connected).to.be.true;
@maxhoheiser
maxhoheiser / index.js
Last active March 17, 2022 15:41
Example index.js file for Synpress
import "./commands";
import "@synthetixio/synpress/support";
@maxhoheiser
maxhoheiser / .env
Created March 16, 2022 13:20
Example env file for Synpress
NETWORK_NAME=localhost
SECRET_WORDS="test, test, test, test, test, test, test, test, test, test, test, junk"
@maxhoheiser
maxhoheiser / login.spec.js
Last active March 17, 2022 15:42
Example test file for Synpress
describe("Login Account", () => {
before(() => {
cy.disconnectMetamaskWalletFromAllDapps();
});
it("Should show connect wallet if not logged in", () => {
cy.visit("/");
cy.findByRole("button", { name: /connect wallet/i }).should("be.visible");
});
@maxhoheiser
maxhoheiser / example.spec.js
Last active March 16, 2022 13:26
Example chain custom Synpress async command
cy.switchMetamaskAccount(1).then((accountSwitched) => {
expect(accountSwitched).to.be.true;
});
cy.confirmMetamaskSignatureRequest().then((confirmed) => {
expect(confirmed).to.be.true;
});
@maxhoheiser
maxhoheiser / .sh
Created March 16, 2022 14:46
Example synrpress
npx synpress run -cf synpress.json --config supportFile='support/index.js'