Fix cypress_spec to run permissions test locally

This commit is contained in:
BlueWinds
2021-10-11 16:19:38 -07:00
parent 7aac450fbb
commit 0d5ff9b9c6
3 changed files with 18 additions and 12 deletions

View File

@@ -705,7 +705,7 @@ const getMsgByType = function (type, arg1 = {}, arg2, arg3) {
return stripIndent`
There is both a \`${arg2}\` and a \`${arg3}\` at the location below:
${arg1}
Cypress does not know which one to read for config. Please remove one of the two and try again.
`
case 'CONFIG_FILE_NOT_FOUND':
@@ -988,7 +988,7 @@ const getMsgByType = function (type, arg1 = {}, arg2, arg3) {
`
case 'CT_NO_DEV_START_EVENT':
return stripIndent`\
To run component-testing, cypress needs the \`dev-server:start\` event.
To run component-testing, cypress needs the \`dev-server:start\` event.
Implement it by adding a \`on('dev-server:start', () => startDevServer())\` call in your pluginsFile.
${arg1 ?

View File

@@ -7,6 +7,7 @@ const { fs } = require('./util/fs')
const glob = require('./util/glob')
const cwd = require('./cwd')
const debug = require('debug')('cypress:server:scaffold')
const errors = require('./errors')
const { isEmpty } = require('ramda')
const { isDefault } = require('./util/config')
@@ -232,7 +233,6 @@ module.exports = {
plugins (folder, config) {
debug(`plugins folder ${folder}`)
// skip if user has explicitly set pluginsFile
if (!config.pluginsFile || !isDefault(config, 'pluginsFile')) {
return Promise.resolve()
@@ -254,6 +254,14 @@ module.exports = {
return this._assertInFileTree(dest, config)
.then(() => {
return fs.copyAsync(src, dest)
}).catch((error) => {
if (error.code === 'EACCES') {
const err = errors.get('ERROR_WRITING_FILE', dest, error)
errors.log(err)
}
throw error
})
},

View File

@@ -108,6 +108,7 @@ describe('lib/cypress', () => {
require('mocha-banner').register()
beforeEach(function () {
process.chdir(previousCwd)
this.timeout(8000)
cache.__removeSync()
@@ -839,17 +840,14 @@ describe('lib/cypress', () => {
// also make sure we test the rest of the integration functionality
// for headed errors! <-- not unit tests, but integration tests!
it('logs error and exits when project folder has read permissions only and cannot write cypress.json', function () {
// test disabled if running as root - root can write all things at all times
if (process.geteuid() === 0) {
return
}
const permissionsPath = path.resolve('./permissions')
const cypressJson = path.join(permissionsPath, 'cypress.json')
return fs.outputFileAsync(cypressJson, '{}')
return fs.mkdirAsync(permissionsPath)
.then(() => {
return fs.outputFileAsync(cypressJson, '{}')
}).then(() => {
// read only
return fs.chmodAsync(permissionsPath, '555')
}).then(() => {
@@ -857,9 +855,9 @@ describe('lib/cypress', () => {
}).then(() => {
return fs.chmodAsync(permissionsPath, '777')
}).then(() => {
return fs.removeAsync(permissionsPath)
}).then(() => {
this.expectExitWithErr('ERROR_READING_FILE', path.join(permissionsPath, 'cypress.json'))
this.expectExitWithErr('ERROR_WRITING_FILE', permissionsPath)
}).finally(() => {
return fs.rmdir(permissionsPath, { recursive: true })
})
})