Skip to content

Commit

Permalink
#120: Fix issue with cy.intercept
Browse files Browse the repository at this point in the history
  • Loading branch information
archfz committed Oct 4, 2021
1 parent bcd0bca commit 3b252e7
Show file tree
Hide file tree
Showing 8 changed files with 464 additions and 388 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ node_modules
test/node_modules
test/cypress/screenshots
test/cypress/videos
test/cypress/fixtures
test/output/out.json
test/output/out.txt
test/output/not/existing/path/out.txt
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,11 @@ directory. You should add `it.only` to the test case you are working on to speed
## Release Notes
#### 3.3.3
- Fix issue with `cy.intercept` overrides not working. [issue](https://github.com/archfz/cypress-terminal-report/issues/120)
- Update cypress to 8.5.0 in tests to confirm support.
#### 3.3.2
- Fix issue with no response on XHR breaking tests. [issue](https://github.com/archfz/cypress-terminal-report/issues/119)
Expand Down
2 changes: 1 addition & 1 deletion src/collector/LogCollectCypressIntercept.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ module.exports = class LogCollectCypressIntercept {
}

this.collectorState.addLog([LOG_TYPE.CYPRESS_INTERCEPT, message, CONSTANTS.SEVERITY.SUCCESS]);
originalFn(...args);
return originalFn(...args);
});
}

Expand Down
1 change: 1 addition & 0 deletions test/cypress/fixtures/example.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<html lang='en'>Interceptor 1</html>
1 change: 1 addition & 0 deletions test/cypress/fixtures/example2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<html lang='en'>Interceptor 2</html>
20 changes: 20 additions & 0 deletions test/cypress/integration/interceptOverride.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Test is not covered. Manually can be checked only as it reproduced in browser only.
describe('Intercept override', () => {
beforeEach(() => {
cy.intercept("GET", "https://example.cypress.io/**", {fixture: "example.html"})
})

it('Should show test', () => {
cy.intercept("GET", "https://example.cypress.io/**", {fixture: "example2.html"})

cy.visit('https://example.cypress.io/todo')
cy.contains("Interceptor 2").should('be.visible')
})

it('Should show test', () => {
cy.intercept("GET", "https://example.cypress.io/**", {body: "<html lang='en'>Interceptor 3</html>"})

cy.visit('https://example.cypress.io/todo')
cy.contains("Interceptor 3").should('be.visible')
})
})
818 changes: 434 additions & 384 deletions test/package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"@babel/preset-env": "^7.4.5",
"@babel/register": "^7.13.16",
"chai": "^4.2.0",
"cypress": "8.3.0",
"cypress-cucumber-preprocessor": "^4.0.1",
"cypress": "8.5.0",
"cypress-cucumber-preprocessor": "^4.3.0",
"fs-extra": "^9.0.1",
"glob": "^7.1.6",
"mocha": "^8.3.2"
Expand Down

0 comments on commit 3b252e7

Please sign in to comment.