Skip to content

Commit 22d2c31

Browse files
authored
chore: Address skipped specs in server package (#22356)
* chore: Un-skip some tests * chore: Unskip more tests * chore: Use exec rather than spawn * chore: Fix test * chore: Remove events_spec tests * chore: Add defaultValue for specPattern option * chore: Remove default value * chore: Use os to determine system arch and platform during testing * chore: Add comment for specPattern defaultValue * chore: Remove comment
1 parent 3ee77a8 commit 22d2c31

File tree

13 files changed

+55
-322
lines changed

13 files changed

+55
-322
lines changed

packages/config/__snapshots__/index.spec.ts.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ exports['config/src/index .getPublicConfigKeys returns list of public config key
226226
"viewportWidth",
227227
"waitForAnimations",
228228
"watchForFileChanges",
229+
"specPattern",
229230
"browsers",
230231
"hosts",
231232
"isInteractive",

packages/config/src/options.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,12 @@ const resolvedOptions: Array<ResolvedConfigOption> = [
419419
canUpdateDuringTestTime: false,
420420
requireRestartOnChange: 'server',
421421
},
422+
// Possibly add a defaultValue for specPattern https://github.com/cypress-io/cypress/issues/22507
423+
{
424+
name: 'specPattern',
425+
validation: validate.isStringOrArrayOfStrings,
426+
canUpdateDuringTestTime: false,
427+
},
422428
]
423429

424430
const runtimeOptions: Array<RuntimeConfigOption> = [

packages/server/test/integration/cli_spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ describe('CLI Interface', () => {
4444
})
4545
})
4646

47-
// TODO:(tgriesser) originally skipped this, not sure why
48-
it.skip('writes out package.json and exits', (done) => {
47+
// This fails on MacOS due to an apparent limit on the buffer size of stdout
48+
it('writes out package.json and exits', (done) => {
4949
return cp.exec('npm run dev -- --return-pkg', { env }, (err, stdout, stderr) => {
5050
if (err) {
5151
done(err)

packages/server/test/integration/cypress_spec.js

Lines changed: 3 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -473,33 +473,6 @@ describe('lib/cypress', () => {
473473
})
474474
})
475475

476-
// NOTE: Removal of fixtures is not supported in new flow
477-
it.skip('removes fixtures when they exist and fixturesFolder is false', function (done) {
478-
ctx.actions.project.setCurrentProjectAndTestingTypeForTestSetup(this.idsPath)
479-
480-
ctx.lifecycleManager.getFullInitialConfig()
481-
.then((cfg) => {
482-
this.cfg = cfg
483-
484-
return fs.statAsync(this.cfg.fixturesFolder)
485-
}).then(() => {
486-
return settings.read(this.idsPath)
487-
}).then((json) => {
488-
json.fixturesFolder = false
489-
490-
return settings.writeForTesting(this.idsPath, json)
491-
}).then(() => {
492-
return cypress.start([`--run-project=${this.idsPath}`])
493-
}).then(() => {
494-
return fs.statAsync(this.cfg.fixturesFolder)
495-
.then(() => {
496-
throw new Error('fixturesFolder should not exist!')
497-
}).catch(() => {
498-
return done()
499-
})
500-
})
501-
})
502-
503476
it('runs project headlessly and displays gui', function () {
504477
return cypress.start([`--run-project=${this.todosPath}`, '--headed'])
505478
.then(() => {
@@ -727,13 +700,12 @@ describe('lib/cypress', () => {
727700
})
728701
})
729702

730-
// TODO: test this
731-
it.skip('logs error and exits when project has cypress.config.js syntax error', function () {
703+
it('logs error and exits when project has cypress.config.js syntax error', function () {
732704
return fs.writeFileAsync(`${this.todosPath}/cypress.config.js`, `module.exports = {`)
733705
.then(() => {
734706
return cypress.start([`--run-project=${this.todosPath}`])
735707
}).then(() => {
736-
this.expectExitWithErr('ERROR_READING_FILE', this.todosPath)
708+
this.expectExitWithErr('CONFIG_FILE_REQUIRE_ERROR', this.todosPath)
737709
})
738710
})
739711

@@ -1143,8 +1115,7 @@ describe('lib/cypress', () => {
11431115
})
11441116

11451117
describe('--config-file', () => {
1146-
// TODO: fix
1147-
it.skip(`with a custom config file fails when it doesn't exist`, function () {
1118+
it(`with a custom config file fails when it doesn't exist`, function () {
11481119
this.filename = 'abcdefgh.test.js'
11491120

11501121
return fs.statAsync(path.join(this.todosPath, this.filename))
@@ -1729,61 +1700,6 @@ describe('lib/cypress', () => {
17291700
})
17301701
})
17311702
})
1732-
1733-
// NOTE: skipped because we want to ensure this is captured in v10
1734-
it.skip('sends warning when baseUrl cannot be verified', function () {
1735-
const bus = new EE()
1736-
const event = { sender: { send: sinon.stub() } }
1737-
const warning = { message: 'Blah blah baseUrl blah blah' }
1738-
1739-
sinon.stub(ServerE2E.prototype, 'open').resolves([2121, warning])
1740-
1741-
return cypress.start(['--port=2121', '--config', 'pageLoadTimeout=1000', '--foo=bar', '--env=baz=baz'])
1742-
.then(() => {
1743-
const options = Events.start.firstCall.args[0]
1744-
1745-
Events.handleEvent(options, bus, event, 123, 'on:project:warning')
1746-
1747-
return Events.handleEvent(options, bus, event, 123, 'open:project', this.todosPath)
1748-
}).then(() => {
1749-
expect(event.sender.send.withArgs('response').firstCall.args[1].data).to.eql(warning)
1750-
})
1751-
})
1752-
1753-
describe('--config-file', () => {
1754-
beforeEach(function () {
1755-
this.filename = 'foo.bar.baz.asdf.quux.json'
1756-
this.open = sinon.stub(ServerE2E.prototype, 'open').resolves([])
1757-
})
1758-
1759-
// TODO: (tgriesser) needs a system test, the mocking here no longer is correct
1760-
it.skip('reads config from a custom config file', function () {
1761-
const bus = new EE()
1762-
1763-
return fs.writeJson(path.join(this.pristinePath, this.filename), {
1764-
env: { foo: 'bar' },
1765-
port: 2020,
1766-
}).then(() => {
1767-
return cypress.start([
1768-
`--config-file=${this.filename}`,
1769-
])
1770-
.then(() => {
1771-
const options = Events.start.firstCall.args[0]
1772-
1773-
return Events.handleEvent(options, bus, {}, 123, 'open:project', this.pristinePath)
1774-
})
1775-
.then(() => {
1776-
expect(this.open).to.be.called
1777-
1778-
const cfg = this.open.getCall(0).args[0]
1779-
1780-
expect(cfg.env.foo).to.equal('bar')
1781-
1782-
expect(cfg.port).to.equal(2020)
1783-
})
1784-
})
1785-
})
1786-
})
17871703
})
17881704

17891705
context('--cwd', () => {

packages/server/test/unit/browsers/firefox_spec.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -279,13 +279,6 @@ describe('lib/browsers/firefox', () => {
279279
})
280280
})
281281

282-
// TODO: pick open port for debugger
283-
it.skip('finds remote port for firefox debugger', function () {
284-
return firefox.open(this.browser, 'http://', this.options, this.automation).then(() => {
285-
// expect(firefoxUtil.findRemotePort).to.be.called
286-
})
287-
})
288-
289282
it('sets proxy-related preferences if specified', function () {
290283
this.options.proxyServer = 'http://proxy-server:1234'
291284

packages/server/test/unit/config_spec.js

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ const config = require(`../../lib/config`)
1111
const errors = require(`../../lib/errors`)
1212
const configUtil = require(`../../lib/util/config`)
1313

14+
const os = require('node:os')
15+
1416
describe('lib/config', () => {
1517
before(function () {
1618
this.env = process.env
@@ -157,18 +159,10 @@ describe('lib/config', () => {
157159
return this.expectValidationPasses()
158160
})
159161

160-
// NOTE: Validated in real use
161-
it.skip('validates cypress.config.js', function () {
162+
it('validates cypress.config.js', function () {
162163
this.setup({ reporter: 5 })
163164

164-
return this.expectValidationFails('cypress.config.{js,ts,mjs,cjs}')
165-
})
166-
167-
// NOTE: Validated in real use
168-
it.skip('validates cypress.env.json', function () {
169-
this.setup({}, { reporter: 5 })
170-
171-
return this.expectValidationFails('cypress.env.json')
165+
return this.expectValidationFails('Expected reporter to be a string')
172166
})
173167

174168
it('only validates known values', function () {
@@ -577,28 +571,27 @@ describe('lib/config', () => {
577571
})
578572
})
579573

580-
// TODO:(lachlan): after mega PR
581-
context.skip('specPattern', () => {
574+
context('specPattern', () => {
582575
it('passes if a string', function () {
583-
this.setup({ e2e: { specPattern: '**/*.coffee' } })
576+
this.setup({ e2e: { supportFile: false, specPattern: '**/*.coffee' } })
584577

585578
return this.expectValidationPasses()
586579
})
587580

588581
it('passes if an array of strings', function () {
589-
this.setup({ e2e: { specPattern: ['**/*.coffee'] } })
582+
this.setup({ e2e: { supportFile: false, specPattern: ['**/*.coffee'] } })
590583

591584
return this.expectValidationPasses()
592585
})
593586

594587
it('fails if not a string or array', function () {
595-
this.setup({ e2e: { specPattern: 42 } })
588+
this.setup({ e2e: { supportFile: false, specPattern: 42 } })
596589

597590
return this.expectValidationFails('be a string or an array of strings')
598591
})
599592

600593
it('fails if not an array of strings', function () {
601-
this.setup({ e2e: { specPattern: [5] } })
594+
this.setup({ e2e: { supportFile: false, specPattern: [5] } })
602595

603596
return this.expectValidationFails('be a string or an array of strings')
604597
.then(() => {
@@ -1466,8 +1459,7 @@ describe('lib/config', () => {
14661459
expect(warning).to.be.calledWith('FIREFOX_GC_INTERVAL_REMOVED')
14671460
})
14681461

1469-
// TODO:(lachlan) after mega PR
1470-
describe.skip('.resolved', () => {
1462+
describe('.resolved', () => {
14711463
it('sets reporter and port to cli', () => {
14721464
const obj = {
14731465
projectRoot: '/foo/bar',
@@ -1483,22 +1475,20 @@ describe('lib/config', () => {
14831475
.then((cfg) => {
14841476
expect(cfg.resolved).to.deep.eq({
14851477
animationDistanceThreshold: { value: 5, from: 'default' },
1478+
arch: { value: os.arch(), from: 'default' },
14861479
baseUrl: { value: null, from: 'default' },
14871480
blockHosts: { value: null, from: 'default' },
14881481
browsers: { value: [], from: 'default' },
14891482
chromeWebSecurity: { value: true, from: 'default' },
14901483
clientCertificates: { value: [], from: 'default' },
1491-
component: { from: 'default', value: {} },
14921484
defaultCommandTimeout: { value: 4000, from: 'default' },
14931485
downloadsFolder: { value: 'cypress/downloads', from: 'default' },
1494-
e2e: { from: 'default', value: {} },
14951486
env: {},
14961487
execTimeout: { value: 60000, from: 'default' },
14971488
experimentalFetchPolyfill: { value: false, from: 'default' },
14981489
experimentalInteractiveRunEvents: { value: false, from: 'default' },
14991490
experimentalSessionAndOrigin: { value: false, from: 'default' },
15001491
experimentalSourceRewriting: { value: false, from: 'default' },
1501-
experimentalStudio: { value: false, from: 'default' },
15021492
fileServerFolder: { value: '', from: 'default' },
15031493
fixturesFolder: { value: 'cypress/fixtures', from: 'default' },
15041494
hosts: { value: null, from: 'default' },
@@ -1509,6 +1499,7 @@ describe('lib/config', () => {
15091499
modifyObstructiveCode: { value: true, from: 'default' },
15101500
numTestsKeptInMemory: { value: 50, from: 'default' },
15111501
pageLoadTimeout: { value: 60000, from: 'default' },
1502+
platform: { value: os.platform(), from: 'default' },
15121503
port: { value: 1234, from: 'cli' },
15131504
projectId: { value: null, from: 'default' },
15141505
redirectionLimit: { value: 20, from: 'default' },
@@ -1525,7 +1516,6 @@ describe('lib/config', () => {
15251516
supportFile: { value: false, from: 'config' },
15261517
supportFolder: { value: false, from: 'default' },
15271518
taskTimeout: { value: 60000, from: 'default' },
1528-
specPattern: { value: '**/*.*', from: 'default' },
15291519
trashAssetsBeforeRuns: { value: true, from: 'default' },
15301520
userAgent: { value: null, from: 'default' },
15311521
video: { value: true, from: 'default' },
@@ -1570,22 +1560,20 @@ describe('lib/config', () => {
15701560
return config.mergeDefaults(obj, options)
15711561
.then((cfg) => {
15721562
expect(cfg.resolved).to.deep.eq({
1563+
arch: { value: os.arch(), from: 'default' },
15731564
animationDistanceThreshold: { value: 5, from: 'default' },
15741565
baseUrl: { value: 'http://localhost:8080', from: 'config' },
15751566
blockHosts: { value: null, from: 'default' },
15761567
browsers: { value: [], from: 'default' },
15771568
chromeWebSecurity: { value: true, from: 'default' },
1578-
component: { from: 'default', value: {} },
15791569
clientCertificates: { value: [], from: 'default' },
15801570
defaultCommandTimeout: { value: 4000, from: 'default' },
15811571
downloadsFolder: { value: 'cypress/downloads', from: 'default' },
1582-
e2e: { from: 'default', value: {} },
15831572
execTimeout: { value: 60000, from: 'default' },
15841573
experimentalFetchPolyfill: { value: false, from: 'default' },
15851574
experimentalInteractiveRunEvents: { value: false, from: 'default' },
15861575
experimentalSessionAndOrigin: { value: false, from: 'default' },
15871576
experimentalSourceRewriting: { value: false, from: 'default' },
1588-
experimentalStudio: { value: false, from: 'default' },
15891577
env: {
15901578
foo: {
15911579
value: 'foo',
@@ -1618,6 +1606,7 @@ describe('lib/config', () => {
16181606
modifyObstructiveCode: { value: true, from: 'default' },
16191607
numTestsKeptInMemory: { value: 50, from: 'default' },
16201608
pageLoadTimeout: { value: 60000, from: 'default' },
1609+
platform: { value: os.platform(), from: 'default' },
16211610
port: { value: 2020, from: 'config' },
16221611
projectId: { value: 'projectId123', from: 'env' },
16231612
redirectionLimit: { value: 20, from: 'default' },
@@ -1634,7 +1623,6 @@ describe('lib/config', () => {
16341623
supportFile: { value: false, from: 'config' },
16351624
supportFolder: { value: false, from: 'default' },
16361625
taskTimeout: { value: 60000, from: 'default' },
1637-
specPattern: { value: '**/*.*', from: 'default' },
16381626
trashAssetsBeforeRuns: { value: true, from: 'default' },
16391627
userAgent: { value: null, from: 'default' },
16401628
video: { value: true, from: 'default' },
@@ -1861,9 +1849,7 @@ describe('lib/config', () => {
18611849
})
18621850
})
18631851

1864-
// TODO: Figure out the behavior on updateWithPluginValues, should we check
1865-
// the config from cfg, or get it from the data-context?
1866-
it.skip('catches browsers=null returned from plugins', () => {
1852+
it('catches browsers=null returned from plugins', () => {
18671853
const browser = {
18681854
name: 'fake browser name',
18691855
family: 'chromium',

0 commit comments

Comments
 (0)