Skip to content

Commit 21dd32b

Browse files
committed
chore: update cypress config for WSL2 compatibility
1 parent a300884 commit 21dd32b

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

cypress.config.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,27 @@ export default defineConfig({
88
},
99
supportFile: './cypress/support/component.ts',
1010
specPattern: 'cypress/e2e/**/*.cy.{js,jsx,ts,tsx}',
11+
video: false,
12+
screenshotOnRunFailure: false,
1113
},
1214
e2e: {
1315
baseUrl: 'http://localhost:3000',
14-
supportFile: false,
16+
supportFile: './cypress/support/e2e.ts',
17+
video: false,
18+
screenshotOnRunFailure: false,
19+
experimentalRunAllSpecs: true,
20+
experimentalStudio: true,
21+
chromeWebSecurity: false,
22+
viewportWidth: 1280,
23+
viewportHeight: 800,
24+
defaultCommandTimeout: 10000,
25+
setupNodeEvents(on, config) {
26+
// Handle WSL2 specific configurations
27+
if (process.env.WSL_DISTRO_NAME) {
28+
config.baseUrl = 'http://localhost:3000';
29+
config.chromeWebSecurity = false;
30+
}
31+
return config;
32+
},
1533
},
1634
});

cypress/e2e/mainPage.cy.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
describe('MainPage Component', () => {
22
const testUsername = 'testuser123';
33

4+
before(() => {
5+
// Handle WSL2 specific setup
6+
if (Cypress.platform === 'linux') {
7+
cy.log('Running in WSL2 environment');
8+
cy.exec('wsl --set-version Ubuntu 2', { failOnNonZeroExit: false });
9+
}
10+
});
11+
412
beforeEach(() => {
513
// Mock the useEntries hook response
614
cy.intercept('GET', '/api/entries', {

cypress/support/e2e.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import './commands';
2+
3+
// Handle WSL2 specific configurations
4+
if (Cypress.platform === 'linux') {
5+
Cypress.config('chromeWebSecurity', false);
6+
Cypress.config('baseUrl', 'http://localhost:3000');
7+
8+
// Add custom commands for WSL2
9+
Cypress.Commands.add('wslExec', (command) => {
10+
return cy.exec(`wsl ${command}`);
11+
});
12+
}

0 commit comments

Comments
 (0)