Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions packages/server/__snapshots__/cypress_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,3 +310,44 @@ The following configuration options are invalid:
https://on.cypress.io/configuration

`

exports['Long Dashboard URL'] = `

====================================================================================================

(Run Starting)

┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Cypress: 10.3.0 │
│ Browser: Electron 99 (headless) │
│ Specs: 1 found (app.cy.js) │
│ Searched: cypress/e2e/**/*.cy.{js,jsx,ts,tsx} │
│ Params: Tag: false, Group: electron-smoke-tests, Parallel: false │
│ Run URL: http://dashboard.cypress.io/this-is-a-long-long-long-long-long-long-long-long-long │
│ -long-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long-l │
│ ong-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long-lon │
│ g-long-long-long-long-long-long-long-long-url │
└────────────────────────────────────────────────────────────────────────────────────────────────┘


────────────────────────────────────────────────────────────────────────────────────────────────────

Running: app.cy.js (1 of 1)

====================================================================================================

(Run Finished)


Spec Tests Passing Failing Pending Skipped
┌────────────────────────────────────────────────────────────────────────────────────────────────┐
│ ✖ 6ms 1 2 3 4 5 │
└────────────────────────────────────────────────────────────────────────────────────────────────┘
✖ 1 of 1 failed (100%) 6ms 1 2 3 4 5


───────────────────────────────────────────────────────────────────────────────────────────────────────

Recorded Run: http://dashboard.cypress.io/this-is-a-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long-long-url

`
3 changes: 1 addition & 2 deletions packages/server/lib/modes/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,10 +409,9 @@ const renderSummaryTable = (runUrl) => {
})

table4.push(['', ''])
table4.push([`Recorded Run: ${formatPath(runUrl, getWidth(table4, 0), 'gray')}`])

console.log(terminal.renderTables(table4))

console.log(` Recorded Run: ${formatPath(runUrl, undefined, 'gray')}`)
console.log('')
}
}
Expand Down
160 changes: 118 additions & 42 deletions packages/server/test/integration/cypress_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,53 @@ const snapshotConsoleLogs = function (name) {
return snapshot(name, stripAnsi(args))
}

function mockEE () {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just moved duplicated code to this function. The implementation was not changed.

const ee = new EE()

ee.kill = () => {
// ughh, would be nice to test logic inside the launcher
// that cleans up after the browser exit
// like calling client.close() if available to let the
// browser free any resources
return ee.emit('exit')
}

ee.destroy = () => {
return ee.emit('closed')
}

ee.isDestroyed = () => {
return false
}

ee.loadURL = () => {}
ee.focusOnWebView = () => {}
ee.webContents = {
debugger: {
on: sinon.stub(),
attach: sinon.stub(),
sendCommand: sinon.stub().resolves(),
},
getOSProcessId: sinon.stub(),
setUserAgent: sinon.stub(),
session: {
clearCache: sinon.stub().resolves(),
setProxy: sinon.stub().resolves(),
setUserAgent: sinon.stub(),
on: sinon.stub(),
removeListener: sinon.stub(),
webRequest: {
onBeforeSendHeaders () {},
},
},
}

ee.maximize = sinon.stub
ee.setSize = sinon.stub

return ee
}

let ctx

describe('lib/cypress', () => {
Expand Down Expand Up @@ -909,48 +956,7 @@ describe('lib/cypress', () => {
beforeEach(() => {
browsers.open.restore()

const ee = new EE()

ee.kill = () => {
// ughh, would be nice to test logic inside the launcher
// that cleans up after the browser exit
// like calling client.close() if available to let the
// browser free any resources
return ee.emit('exit')
}

ee.destroy = () => {
return ee.emit('closed')
}

ee.isDestroyed = () => {
return false
}

ee.loadURL = () => {}
ee.focusOnWebView = () => {}
ee.webContents = {
debugger: {
on: sinon.stub(),
attach: sinon.stub(),
sendCommand: sinon.stub().resolves(),
},
getOSProcessId: sinon.stub(),
setUserAgent: sinon.stub(),
session: {
clearCache: sinon.stub().resolves(),
setProxy: sinon.stub().resolves(),
setUserAgent: sinon.stub(),
on: sinon.stub(),
removeListener: sinon.stub(),
webRequest: {
onBeforeSendHeaders () {},
},
},
}

ee.maximize = sinon.stub
ee.setSize = sinon.stub
const ee = mockEE()

sinon.stub(launch, 'launch').returns(ee)
sinon.stub(Windows, 'create').returns(ee)
Expand Down Expand Up @@ -1140,9 +1146,52 @@ describe('lib/cypress', () => {
context('--record', () => {
beforeEach(function () {
sinon.stub(api, 'createRun').resolves()
const createInstanceStub = sinon.stub(api, 'createInstance')

createInstanceStub.onFirstCall().resolves({
spec: 'cypress/e2e/app.cy.js',
runs: [{}],
runId: '1',
claimedInstances: 1,
totalInstances: 1,
groupId: 1,
platform: 'linux',
machineId: 1,
})

createInstanceStub.onSecondCall().resolves({
spec: null,
runs: [{}],
runId: '1',
claimedInstances: 1,
totalInstances: 1,
groupId: 1,
platform: 'linux',
machineId: 1,
})

sinon.stub(electron.app, 'on').withArgs('ready').yieldsAsync()
sinon.stub(browsers, 'open')
sinon.stub(runMode, 'waitForSocketConnection').resolves()

sinon.stub(runMode, 'waitForBrowserToConnect').resolves({
stats: {
tests: 1,
passes: 2,
failures: 3,
pending: 4,
skipped: 5,
wallClockDuration: 6,
},
tests: [],
hooks: [],
video: 'path/to/video',
shouldUploadVideo: true,
screenshots: [],
config: {},
spec: {},
})

sinon.stub(runMode, 'waitForTestsToFinishRunning').resolves({
stats: {
tests: 1,
Expand Down Expand Up @@ -1335,6 +1384,33 @@ describe('lib/cypress', () => {
})
})

beforeEach(() => {
browsers.open.restore()

const ee = mockEE()

sinon.stub(launch, 'launch').returns(ee)
sinon.stub(Windows, 'create').returns(ee)
})

it('does not truncate a really long dashboard url', function () {
api.createRun.resolves({
warnings: [],
runUrl: `http://dashboard.cypress.io/this-is-a${'-long'.repeat(50)}-url`,
})

return cypress.start([
`--run-project=${this.recordPath}`,
'--record',
'--key=token-123',
'--group=electron-smoke-tests',
'--ciBuildId=ciBuildId123',
])
.then(() => {
return snapshotConsoleLogs('Long Dashboard URL')
})
})

it('errors and exits when group name is not unique and explicitly passed ciBuildId', function () {
const err = new Error()

Expand Down
7 changes: 2 additions & 5 deletions packages/server/test/scripts/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ if (run[0] && run[0].includes('--inspect-brk')) {

if (options['glob-in-dir']) {
if (run[0]) {
run = [
path.join(options['glob-in-dir'], '**', `*${run[0]}*`),
path.join(options['glob-in-dir'], `*${run[0]}*`),
]
run = [path.join(options['glob-in-dir'], '**', `*${run[0]}*`)]
} else {
run = [path.join(options['glob-in-dir'], '**')]
}
Expand Down Expand Up @@ -55,7 +52,7 @@ if (!run || !run.length) {

$ yarn test-unit
$ yarn test-integration
$ yarn test-e2e
$ yarn test-performance
`)
}

Expand Down
13 changes: 7 additions & 6 deletions system-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,23 @@ These tests run in CI in Electron, Chrome, and Firefox under the `system-tests`
## Running System Tests

```bash
yarn test <path/to/test>
yarn test test/async_timeouts_spec.js
## or
yarn test async_timeouts ## shorthand, uses globbing to find spec
yarn test # runs all tests
## or use globbing to find spec in folders as defined in "glob-in-dir" param in package.json
yarn test screenshot*element # runs screenshot_element_capture_spec.js
yarn test screenshot # runs screenshot_element_capture_spec.js, screenshot_fullpage_capture_spec.js, ..., etc.

```

To keep the browser open after a spec run (for easier debugging and iterating on specs), you can pass the `--no-exit` flag to the test command. Live reloading due to spec changes should also work:

```sh
yarn test test/go_spec.js --browser chrome --no-exit
yarn test go_spec.js --browser chrome --no-exit
```

To debug the Cypress process under test, you can pass `--cypress-inspect-brk`:

```sh
yarn test test/go_spec.js --browser chrome --no-exit --cypress-inspect-brk
yarn test go_spec.js --browser chrome --no-exit --cypress-inspect-brk
```

## Developing Tests
Expand Down
Loading