Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(server): remove redundant supportFile check #23543

Merged
merged 7 commits into from
Aug 29, 2022
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
// Volar is the main extension that powers Vue's language features.
// These are commented out because they slow down node development
// "volar.autoCompleteRefs": false,
"volar.takeOverMode.enabled": true,
"volar.takeOverMode.enabled": "auto",

"editor.tabSize": 2,
}
3 changes: 0 additions & 3 deletions packages/server/lib/project-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import * as config from './config'
import * as errors from './errors'
import preprocessor from './plugins/preprocessor'
import runEvents from './plugins/run_events'
import { checkSupportFile } from './project_utils'
import Reporter from './reporter'
import * as savedState from './saved_state'
import { ServerCt } from './server-ct'
Expand Down Expand Up @@ -224,8 +223,6 @@ export class ProjectBase<TServer extends Server> extends EE {

await this.saveState(stateToSave)

await checkSupportFile(cfg.supportFile)

if (cfg.isTextTerminal) {
return
}
Expand Down
14 changes: 0 additions & 14 deletions packages/server/lib/project_utils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import Debug from 'debug'
import path from 'path'
import * as errors from './errors'
import { escapeFilenameInUrl } from './util/escape_filename'
import { fs } from './util/fs'

const debug = Debug('cypress:server:project_utils')

Expand Down Expand Up @@ -35,15 +33,3 @@ export const getSpecUrl = ({

return specUrl
}

export const checkSupportFile = async (supportFile: Cypress.Config['supportFile']) => {
if (supportFile && typeof supportFile === 'string') {
const found = await fs.pathExists(supportFile)

if (!found) {
errors.throwErr('SUPPORT_FILE_NOT_FOUND', supportFile)
}
}

return
}
2 changes: 2 additions & 0 deletions packages/server/lib/server-e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ export class ServerE2E extends ServerBase<SocketE2E> {
return ensureUrl.isListening(baseUrl)
.return(null)
.catch((err) => {
debug(err)
emilyrohrbough marked this conversation as resolved.
Show resolved Hide resolved

return errors.get('CANNOT_CONNECT_BASE_URL_WARNING', baseUrl)
})
}
Expand Down
11 changes: 0 additions & 11 deletions packages/server/test/unit/project_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const config = require(`../../lib/config`)
const scaffold = require(`../../lib/scaffold`)
const { ServerE2E } = require(`../../lib/server-e2e`)
const { ProjectBase } = require(`../../lib/project-base`)
const ProjectUtils = require(`../../lib/project_utils`)
const { Automation } = require(`../../lib/automation`)
const savedState = require(`../../lib/saved_state`)
const plugins = require(`../../lib/plugins`)
Expand Down Expand Up @@ -255,7 +254,6 @@ This option will not have an effect in Some-other-name. Tests that rely on web s
context('#open', () => {
beforeEach(function () {
sinon.stub(this.project, 'startWebsockets')
this.checkSupportFileStub = sinon.stub(ProjectUtils, 'checkSupportFile').resolves()
sinon.stub(this.project, 'scaffold').resolves()
sinon.stub(this.project, 'getConfig').returns(this.config)
sinon.stub(ServerE2E.prototype, 'open').resolves([])
Expand Down Expand Up @@ -295,15 +293,6 @@ This option will not have an effect in Some-other-name. Tests that rely on web s
})
})

it('calls checkSupportFile with server config when scaffolding is finished', function () {
return this.project.open().then(() => {
expect(this.checkSupportFileStub).to.be.calledWith({
configFile: 'cypress.config.js',
supportFile: false,
})
})
})

it('initializes the plugins', function () {
return this.project.open().then(() => {
expect(plugins.init).to.be.called
Expand Down
25 changes: 1 addition & 24 deletions packages/server/test/unit/project_utils_spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import Chai from 'chai'
import path from 'path'
import { getSpecUrl, checkSupportFile } from '../../lib/project_utils'
import { getSpecUrl } from '../../lib/project_utils'
import Fixtures from '@tooling/system-tests'
import stripAnsi from 'strip-ansi'

const todosPath = Fixtures.projectPath('todos')

Expand Down Expand Up @@ -93,26 +92,4 @@ describe('lib/project_utils', () => {
expect(str).to.eq('http://localhost:8888/__/#/specs/runner?file=tests/s%25%26%3Fub/a.spec.js')
})
})

describe('checkSupportFile', () => {
it('does nothing when {supportFile: false}', async () => {
const ret = await checkSupportFile({
configFile: 'cypress.config.ts',
supportFile: false,
})

expect(ret).to.be.undefined
})

it('throws when support file does not exist', async () => {
try {
await checkSupportFile({
configFile: 'cypress.config.ts',
supportFile: '/this/file/does/not/exist/foo/bar/cypress/support/e2e.js',
})
} catch (e) {
expect(stripAnsi(e.message)).to.include('Your supportFile is missing or invalid')
}
})
})
})