Skip to content

Commit 7f8fc87

Browse files
Merge pull request #686 from centrica-engineering/hotfix/cypress
Fix muon cypress test failures in browserstack
2 parents ccd3fa3 + 6ebd110 commit 7f8fc87

File tree

10 files changed

+114
-78
lines changed

10 files changed

+114
-78
lines changed

.github/workflows/browserstack.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,18 @@ jobs:
1616
with:
1717
username: ${{ secrets.BROWSER_STACK_USERNAME }}
1818
access-key: ${{ secrets.BROWSER_STACK_ACCESS_KEY }}
19+
- uses: browserstack/github-actions/setup-local@master
20+
with:
21+
local-testing: start
22+
local-identifier: CypressLocalConnection1
1923
- uses: bahmutov/npm-install@v1
20-
- run: npm run test:cypress:browserstack
24+
- name: Run BrowserStack Tests
25+
run: npm run test:cypress:browserstack
26+
timeout-minutes: 15
27+
env:
28+
BROWSERSTACK_USERNAME: ${{ secrets.BROWSER_STACK_USERNAME }}
29+
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSER_STACK_ACCESS_KEY }}
30+
- uses: browserstack/github-actions/setup-local@master
31+
if: always()
32+
with:
33+
local-testing: stop

browserstack.json

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,14 @@
66
"versions": [
77
"latest"
88
]
9-
},
10-
{
11-
"browser": "firefox",
12-
"os": "OS X Ventura",
13-
"versions": [
14-
"latest"
15-
]
169
}
1710
],
1811
"run_settings": {
1912
"cypress_config_file": "./cypress.config.js",
2013
"cypress_version": "13",
2114
"cache_dependencies": "true",
2215
"specs": [
23-
"cypress/e2e/component_tests/*.feature",
24-
"cypress/e2e/example_app_tests/*.feature"
16+
"cypress/**/*.feature"
2517
],
2618
"npm_dependencies": {
2719
"@badeball/cypress-cucumber-preprocessor": "21.0.3",
@@ -37,26 +29,26 @@
3729
"build_name": "muon-cypress",
3830
"package_config_options": {
3931
"cypress-cucumber-preprocessor": {
40-
"nonGlobalStepDefinitions": false,
41-
"stepDefinitions": [
42-
"cypress/e2e/component_tests/**/*.{js,ts}",
43-
"cypress/e2e/example_app_tests/**/*.{js,ts}"
44-
]
32+
"nonGlobalStepDefinitions": true
4533
}
4634
},
47-
"spec_timeout": 30,
35+
"spec_timeout": 10,
4836
"test_timeout": 300,
4937
"idle_timeout": 300,
50-
"parallels": "2",
51-
"sync": true,
52-
"exclude": [],
53-
"headless": true,
54-
"record_video": false,
55-
"record_screenshots": false
38+
"parallels": "5",
39+
"exclude": []
5640
},
5741
"connection_settings": {
5842
"local": true,
5943
"local_mode": "always-on",
60-
"local_identifier": "CypressLocalConnection1"
61-
}
62-
}
44+
"local_identifier": "CypressLocalConnection1",
45+
"local_args": {
46+
"force": "true",
47+
"forcelocal": "true",
48+
"binarypath": "${BROWSERSTACK_BINARY_PATH}",
49+
"verbose": "true"
50+
}
51+
},
52+
"disable_usage_reporting": false,
53+
"key": "auth"
54+
}

cypress/e2e/component_tests/muon_cta/muon_cta.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11

2-
import {Then} from '@badeball/cypress-cucumber-preprocessor';
2+
import {Given, Then} from '@badeball/cypress-cucumber-preprocessor';
3+
4+
Given('Launch the {string} component {string} type in the browser', (component, type) => {
5+
cy.launchComponent(component, type);
6+
});
37

48
Then('Validate the elements and attributes in the {string} component', (type) => {
59

cypress/e2e/component_tests/muon_detail/muon_detail.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
/* eslint-disable no-undef */
2-
import { When, Then } from '@badeball/cypress-cucumber-preprocessor';
2+
import { Given , When, Then } from '@badeball/cypress-cucumber-preprocessor';
33

4+
Given('Launch the {string} component {string} type in the browser', (component, type) => {
5+
cy.launchComponent(component, type);
6+
});
47

58
When('User clicks to expand the detail', () => {
69
cy.get('muon-detail').find('div[slot="heading"]').click();

cypress/e2e/component_tests/muon_form/muon_form.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor';
33
import {formElement} from '../../../support/web_elements';
44

5+
Given('Launch the {string} component {string} type in the browser', (component, type) => {
6+
cy.launchComponent(component, type);
7+
});
58

69
When('User enters values in all fields', () => {
710
cy.get('form').invoke('attr','novalidate').should('eq','true')

cypress/e2e/component_tests/muon_icon/muon_icon.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
/* eslint-disable no-undef */
22
import { Given, Then } from '@badeball/cypress-cucumber-preprocessor';
33

4+
Given('Launch the {string} component {string} type in the browser', (component, type) => {
5+
cy.launchComponent(component, type);
6+
});
47

58
Then('Validate the svg element', () => {
69
cy.get('muon-icon')

cypress/e2e/component_tests/muon_image/muon_image.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
/* eslint-disable no-undef */
22
{/* <reference types="cypress" /> */}
33

4-
import { Then } from '@badeball/cypress-cucumber-preprocessor';
4+
import { Given, Then } from '@badeball/cypress-cucumber-preprocessor';
55
import {imageElement} from '../../../support/web_elements';
66

7+
Given('Launch the {string} component {string} type in the browser', (component, type) => {
8+
cy.launchComponent(component, type);
9+
});
710

811
Then('Validate the image src and elements in {string} type', (type) => {
912

cypress/e2e/component_tests/muon_inputter/muon_inputter.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor';
44
import {inputElement} from '../../../support/web_elements';
55

6+
Given('Launch the {string} component {string} type in the browser', (component, type) => {
7+
cy.launchComponent(component, type);
8+
});
9+
610
When('User enter the input', () => {
711
cy.clearInput();
812
cy.enterValue('Cypress test');

package-lock.json

Lines changed: 55 additions & 48 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,15 @@
1717
"test:axe": "npm run build && axe-storybook",
1818
"test:snapshots": "npm run test --workspace=@muonic/muon -- --update-snapshots",
1919
"test:browserstack": "npm run test:browserstack --workspace=@muonic/muon",
20+
"start:dev": "npm run dev --no-open",
21+
"test:component:browserstack": "browserstack-cypress run --spec 'cypress/e2e/component_tests/*.feature' --build-name 'muon-component-cypress' --exit || true",
22+
"start:ember": "npm run open:ember",
23+
"test:ember:browserstack": "browserstack-cypress run --spec 'cypress/e2e/example_app_tests/*.feature' --build-name 'muon-ember-cypress' --exit",
2024
"test:cypress:open": "start-server-and-test 'npm run dev --no-open' 8000 'npm run cypress -- open'",
2125
"test:cypress:component": "start-server-and-test 'npm run dev --no-open' 8000 'npm run cypress -- run --browser chrome --spec \"cypress/e2e/component_tests/*.feature\" --env allure=true || echo \"The previous command has some errors..Continuing\"'",
2226
"test:cypress:ember": "start-server-and-test 'npm run open:ember' 4200 'npm run cypress -- run --browser chrome --spec \"cypress/e2e/example_app_tests/*.feature\" --env allure=true || echo \"The previous command has some errors..Continuing\"'",
2327
"test:cypress:local": "rm -rf allure-report allure-results && npm run test:cypress:component && npm run test:cypress:ember && npm run test:allure:report",
24-
"test:cypress:browserstack": "start-server-and-test 'npm run dev --no-open' 8000 'npm run open:ember' 4200 'browserstack-cypress run'",
28+
"test:cypress:browserstack": "start-server-and-test start:dev 8000 test:component:browserstack && start-server-and-test start:ember 4200 test:ember:browserstack",
2529
"test:allure:report": "allure generate --single-file allure-results --clean -o allure-report && allure open allure-report",
2630
"test:cypress:tag": "start-server-and-test 'npm run dev --no-open' 8000 'npm run open:ember' 4200 './node_modules/.bin/cypress-tags run -e TAGS=\"@form\" --browser chrome'",
2731
"test:percy": "start-server-and-test 'npm run dev --no-open' 8000 'percy storybook http://localhost:8000'",
@@ -69,7 +73,7 @@
6973
"husky": "8.0.3",
7074
"npm-run-all": "4.1.5",
7175
"standard-version": "9.5.0",
72-
"start-server-and-test": "2.0.0",
76+
"start-server-and-test": "^2.0.13",
7377
"stylelint": "15.6.1",
7478
"stylelint-config-standard": "33.0.0"
7579
},

0 commit comments

Comments
 (0)