mirror of
https://github.com/cypress-io/cypress.git
synced 2026-01-21 22:50:13 -06:00
* revive logic to run CT in a single tab * add feature flag: experimentalSingleTabRunMode * remove log * reset browser state between tests * document single tab run mode experiment; * add system test for experimental run mode * fix snapshots * use more simple project for testing * additional guard; * fix test * Apply suggestions from code review Co-authored-by: Emily Rohrbough <emilyrohrbough@users.noreply.github.com> * destroy aut after each spec * update snapshot * fix types * add experiment flag error * add warning when using experimental flag with e2e * build binaries for experimentalSingleTabRunMode feature * build binaries take 2 * make error message more open ended * destroy AUT later in run mode lifecycle * add additional assertion around experimental flag * simplify error * remove test code from production code Co-authored-by: Emily Rohrbough <emilyrohrbough@users.noreply.github.com>
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
import Debug from 'debug'
|
|
import devServer from '@packages/server/lib/plugins/dev-server'
|
|
import { SocketBase } from '@packages/server/lib/socket-base'
|
|
import dfd from 'p-defer'
|
|
import type { Socket } from '@packages/socket'
|
|
import type { DestroyableHttpServer } from '@packages/server/lib/util/server_destroy'
|
|
import assert from 'assert'
|
|
|
|
const debug = Debug('cypress:server:socket-ct')
|
|
|
|
export class SocketCt extends SocketBase {
|
|
#destroyAutPromise?: dfd.DeferredPromise<void>
|
|
|
|
constructor (config: Record<string, any>) {
|
|
super(config)
|
|
|
|
// should we use this option at all for component testing 😕?
|
|
if (config.watchForFileChanges) {
|
|
devServer.emitter.on('dev-server:compile:success', ({ specFile }) => {
|
|
this.toRunner('dev-server:compile:success', { specFile })
|
|
})
|
|
}
|
|
}
|
|
|
|
startListening (server: DestroyableHttpServer, automation, config, options) {
|
|
return super.startListening(server, automation, config, options, {
|
|
onSocketConnection: (socket: Socket) => {
|
|
debug('do onSocketConnection')
|
|
|
|
socket.on('aut:destroy:complete', () => {
|
|
assert(this.#destroyAutPromise)
|
|
this.#destroyAutPromise.resolve()
|
|
})
|
|
},
|
|
})
|
|
}
|
|
|
|
destroyAut () {
|
|
this.#destroyAutPromise = dfd()
|
|
|
|
this.toRunner('aut:destroy:init')
|
|
|
|
return this.#destroyAutPromise.promise
|
|
}
|
|
}
|