Skip to content

Commit

Permalink
update the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bahmutov committed Jul 13, 2022
1 parent af9c7e0 commit 5ea06dc
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 58 deletions.
99 changes: 49 additions & 50 deletions __snapshots__/cypress-failed-log-spec.js
Original file line number Diff line number Diff line change
@@ -1,77 +1,76 @@
exports['saved commands from test-page2-spec.js finds xhr'] = [
"visit test-page2.html",
"get #triggerXHR",
"click ",
"xhr GET http://localhost:9999/test-page2.json",
"xhr STUBBED GET http://localhost:9999/test-page3.json",
"log fail on purpose, no such text",
"wrap {foo: bar}",
"assert expected **{ foo: bar }** to deeply equal **{ foo: bar }**",
"contains this text does not exist",
"assert expected **:not(script,style):cy-contains('this text does not exist'), [type='submit'][value~='this text does not exist']** to be **visible**"
]

exports['saved commands from test-page1-spec.js finds aliens'] = [
"visit test-page1.html",
"log fail on purpose, no such text",
"wrap {foo: bar}",
"assert expected **{ foo: bar }** to deeply equal **{ foo: bar }**",
"contains this text does not exist",
"assert expected **:not(script,style):cy-contains('this text does not exist'), [type='submit'][value~='this text does not exist']** to be **visible**"
]

exports['saved commands from a.js has second test (failing)'] = [
"wrap {foo: 42}",
"its .foo",
"assert expected **42** to equal **2**"
]

exports['saved commands from a.js has third test (failing)'] = [
"wrap foo",
"assert expected **foo** to equal **bar**"
]

exports['saved commands from long-name-spec.js 184-188-192-196-2001'] = [
"log file name short enough",
"visit https://example.cypress.io",
"url ",
"assert expected **https://example.cypress.io/** to include **google**"
]

exports['saved commands from long-name-spec.js 184-188-192-196-200-204-208-212-216-220-224-228-232-236-240-244-248-252-2561'] = [
"log file name too long",
"get .nonexistent-selector",
"assert expected **.nonexistent-selector** to exist in the DOM"
]

exports['spec a.js finished with'] = {
exports['spec cypress/e2e/a.cy.js finished with'] = {
"totalTests": 4,
"totalFailed": 2,
"totalPassed": 2,
"totalPending": 0,
"totalSkipped": 0
}

exports['spec test-page1-spec.js finished with'] = {
exports['spec cypress/e2e/test-page1.cy.js finished with'] = {
"totalTests": 1,
"totalFailed": 1,
"totalPassed": 0,
"totalPending": 0,
"totalSkipped": 0
}

exports['spec test-page2-spec.js finished with'] = {
exports['spec cypress/e2e/test-page2.cy.js finished with'] = {
"totalTests": 1,
"totalFailed": 1,
"totalPassed": 0,
"totalPending": 0,
"totalSkipped": 0
}

exports['spec long-name-spec.js finished with'] = {
exports['spec cypress/e2e/long-name.cy.js finished with'] = {
"totalTests": 2,
"totalFailed": 2,
"totalPassed": 0,
"totalPending": 0,
"totalSkipped": 0
}

exports['saved commands from cypress/e2e/test-page1.cy.js finds aliens'] = [
"visit test-page1.html",
"log fail on purpose, no such text",
"wrap {foo: bar}",
"assert expected **{ foo: bar }** to deeply equal **{ foo: bar }**",
"contains this text does not exist",
"assert expected **:cy-contains('this text does not exist'), [type='submit'][value~='this text does not exist']** to be **visible**"
]

exports['saved commands from cypress/e2e/test-page2.cy.js finds xhr'] = [
"visit test-page2.html",
"get #triggerXHR",
"click ",
"xhr GET http://localhost:9999/test-page2.json",
"xhr STUBBED GET http://localhost:9999/test-page3.json",
"log fail on purpose, no such text",
"wrap {foo: bar}",
"assert expected **{ foo: bar }** to deeply equal **{ foo: bar }**",
"contains this text does not exist",
"assert expected **:cy-contains('this text does not exist'), [type='submit'][value~='this text does not exist']** to be **visible**"
]

exports['saved commands from cypress/e2e/long-name.cy.js 184-188-192-196-2001'] = [
"log file name too long",
"get .nonexistent-selector",
"assert expected **.nonexistent-selector** to exist in the DOM"
]

exports['saved commands from cypress/e2e/long-name.cy.js 184-188-192-196-200-204-208-212-216-220-224-228-232-236-240-244-248-252-2561'] = [
"log file name too long",
"get .nonexistent-selector",
"assert expected **.nonexistent-selector** to exist in the DOM"
]

exports['saved commands from cypress/e2e/a.cy.js has second test (failing)'] = [
"wrap {foo: 42}",
"its .foo",
"assert expected **42** to equal **2**"
]

exports['saved commands from cypress/e2e/a.cy.js has third test (failing)'] = [
"wrap foo",
"assert expected **foo** to equal **bar**"
]
14 changes: 7 additions & 7 deletions src/cypress-failed-log-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe('cypress-failed-log', () => {
})

it('runs spec a', () => {
const spec = 'cypress/integration/a.js'
const spec = 'cypress/e2e/a.cy.js'
terminalBanner(`Starting spec ${spec} at ${new Date()}`, '*')

return cypress
Expand Down Expand Up @@ -98,8 +98,8 @@ describe('cypress-failed-log', () => {
})
})

it('runs spec test-page1-spec', () => {
const spec = 'cypress/integration/test-page1-spec.js'
it('runs spec test-page1', () => {
const spec = 'cypress/e2e/test-page1.cy.js'
terminalBanner(`Starting spec ${spec} at ${new Date()}`, '*')

return cypress
Expand All @@ -126,8 +126,8 @@ describe('cypress-failed-log', () => {
})
})

it('runs spec test-page2-spec', () => {
const spec = 'cypress/integration/test-page2-spec.js'
it('runs spec test-page2', () => {
const spec = 'cypress/e2e/test-page2.cy.js'
terminalBanner(`Starting spec ${spec} at ${new Date()}`, '*')

return cypress
Expand Down Expand Up @@ -159,8 +159,8 @@ describe('cypress-failed-log', () => {
})
})

it('runs spec long-name-spec', () => {
const spec = 'cypress/integration/long-name-spec.js'
it('runs spec long-name', () => {
const spec = 'cypress/e2e/long-name.cy.js'
terminalBanner(`Starting spec ${spec} at ${new Date()}`, '*')

return cypress
Expand Down
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ function onFailed () {
// const testCommands = reject(commands.filter(notEmpty), duplicate)
const testCommands = Cypress._.map(commands, 'message')

const specName = path.basename(window.location.pathname)
// const specName = path.basename(window.location.pathname)
const specName = Cypress.spec.relative

console.log('=== test failed ===')
console.log(specName)
Expand Down

0 comments on commit 5ea06dc

Please sign in to comment.