Skip to content

Commit 1af3f9e

Browse files
committed
fix(dapp-example): migrate Synpress from v3 to v4 API
- Update test script to use Cypress CLI instead of deprecated Synpress CLI - Rename synpress.js to cypress.config.js for standard Cypress convention - Update configuration to use configureSynpressForMetaMask from v4 API - Update support file to use synpressCommandsForMetaMask from v4 API - Add testIsolation: false required for Synpress v4 - Remove manual webpack preprocessor configuration (handled by v4) This resolves the 'unknown option: -cf' error when running npm test. Signed-off-by: Logan Nguyen <[email protected]>
1 parent 15f01d6 commit 1af3f9e

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

dapp-example/synpress.js renamed to dapp-example/cypress.config.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
const { defineConfig } = require('cypress');
2-
const path = require('path');
3-
const synpressPath = path.dirname(require.resolve('@synthetixio/synpress'));
4-
const preprocessor = require('@cypress/webpack-batteries-included-preprocessor');
2+
const { configureSynpressForMetaMask } = require('@synthetixio/synpress/cypress');
53

64
module.exports = defineConfig({
75
userAgent: 'synpress',
8-
fixturesFolder: `${synpressPath}/fixtures`,
96
screenshotsFolder: 'screenshots',
107
videosFolder: 'videos',
118
chromeWebSecurity: true,
@@ -26,15 +23,13 @@ module.exports = defineConfig({
2623
openMode: 0,
2724
},
2825
e2e: {
29-
setupNodeEvents: (on, config) => {
30-
const { defaultOptions } = preprocessor;
31-
defaultOptions.webpackOptions.module.rules[1].exclude = [/browserslist/];
32-
on('file:preprocessor', preprocessor(defaultOptions));
33-
require(`${synpressPath}/plugins/index`)(on, config);
26+
async setupNodeEvents(on, config) {
27+
return configureSynpressForMetaMask(on, config);
3428
},
3529
baseUrl: 'http://localhost:3000',
3630
specPattern: 'tests/e2e/specs/**/*.{js,jsx,ts,tsx}',
3731
supportFile: 'tests/e2e/support.js',
32+
testIsolation: false,
3833
},
3934
reporter: 'cypress-multi-reporters',
4035
reporterOptions: {

dapp-example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"start": "react-scripts start --openssl-legacy-provider",
4747
"build": "react-scripts build --openssl-legacy-provider",
4848
"bootstrap": "env-cmd node tests/e2e/bootstrap.js",
49-
"test": "env-cmd npx synpress run -cf synpress.js",
49+
"test": "env-cmd npx cypress run --browser chrome --headed",
5050
"start-prod": "http-server build -p 3000 -a localhost",
5151
"eject": "react-scripts eject",
5252
"test:ci": "npm ci && npm run bootstrap && npm run build && start-server-and-test 'start' http-get://localhost:3000 'npm run test'"

dapp-example/tests/e2e/support.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
import '@synthetixio/synpress/support/index';
1+
import { synpressCommandsForMetaMask } from '@synthetixio/synpress/cypress/support';
2+
3+
synpressCommandsForMetaMask();

0 commit comments

Comments
 (0)