Skip to content

Commit

Permalink
bonus 39
Browse files Browse the repository at this point in the history
  • Loading branch information
bahmutov committed May 4, 2023
1 parent e612129 commit fb6d845
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
6 changes: 6 additions & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ module.exports = defineConfig({
setupNodeEvents(cypressOn, config) {
// implement node event listeners here
// and load any plugins that require the Node environment
console.log('the base url', config.baseUrl)
if (!config.baseUrl.includes('localhost')) {
console.log('disabled the code coverage plugin')
config.env.coverage = false
}

// fix https://github.com/cypress-io/cypress/issues/22428
const on = cypressOnFix(cypressOn)
cypressSplit(on, config)
Expand Down
5 changes: 4 additions & 1 deletion cypress/e2e/cart/add-to-cart.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { LoginPage } from '@support/pages/login.page'
import { InventoryPage } from '@support/pages/inventory.page'
import { LoginInfo } from '..'

const isLocal = Cypress.config('baseUrl')?.includes('local')

describe('Cart', () => {
// create a small type on the fly using jsdoc comment
// just to help type check help us
Expand All @@ -15,7 +17,8 @@ describe('Cart', () => {
// or restore the previous user session
beforeEach(() => {
LoginPage.login(user.username, user.password)
cy.visit('/inventory.html')
const pageUrl = isLocal ? '/inventory.html' : '/?/inventory.html'
cy.visit(pageUrl)
cy.location('pathname').should('equal', '/inventory.html')
})

Expand Down
5 changes: 4 additions & 1 deletion cypress/e2e/inventory/product-ids.cy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { LoginPage } from '@support/pages/login.page'

const isLocal = Cypress.config('baseUrl')?.includes('local')

describe('Products', () => {
// create a small type on the fly using jsdoc comment
// just to help type check help us
Expand All @@ -14,7 +16,8 @@ describe('Products', () => {
// or restore the previous user session
beforeEach(() => {
LoginPage.login(user.username, user.password)
cy.visit('/inventory.html')
const pageUrl = isLocal ? '/inventory.html' : '/?/inventory.html'
cy.visit(pageUrl)
cy.location('pathname').should('equal', '/inventory.html')
})

Expand Down
5 changes: 4 additions & 1 deletion cypress/e2e/login/direct-attempt.cy.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { LoginPage } from '@support/pages/login.page'

const isLocal = Cypress.config('baseUrl')?.includes('local')

describe('anonymous user', () => {
it('gets an error trying to visit the inventory page', () => {
cy.visit('/inventory.html')
const pageUrl = isLocal ? '/inventory.html' : '/?/inventory.html'
cy.visit(pageUrl)
// confirm we are on root page
// https://on.cypress.io/location
cy.location('pathname').should('equal', '/')
Expand Down

0 comments on commit fb6d845

Please sign in to comment.