Skip to content

Commit b507141

Browse files
chore: update packages/example deployment script and cleanup package/example (#25091)
Co-authored-by: Bill Glesias <bglesias@gmail.com>
1 parent 5afe19f commit b507141

File tree

28 files changed

+149
-183
lines changed

28 files changed

+149
-183
lines changed

npm/create-cypress-tests/scripts/example.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,13 @@ program
1313
await fs.remove(destinationPath)
1414
await fs.copy(exampleFolder, destinationPath, { recursive: true })
1515

16-
console.log(`✅ Example was successfully created at ${chalk.cyan(destination)}`)
16+
console.log(`✅ E2E Examples were successfully created at ${chalk.cyan(destination)}`)
1717

18-
await fs.copy(path.join(__dirname, 'example-tsconfig.json'), path.join(destination, 'tsconfig.json'))
18+
await fs.copy(path.join(__dirname, 'examples', 'cypress'), path.join(destination))
19+
20+
console.log(`✅ Cypress Setup was successfully created at ${chalk.cyan(destination)}`)
21+
22+
await fs.copy(path.join(__dirname, 'examples', 'tsconfig.json'), path.join(destination, 'tsconfig.json'))
1923

2024
console.log(`✅ tsconfig.json was created for ${chalk.cyan(destination)}`)
2125
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// ***********************************************************
2+
// This example support/component.js is processed and
3+
// loaded automatically before your test files.
4+
//
5+
// This is a great place to put global configuration and
6+
// behavior that modifies Cypress.
7+
//
8+
// You can change the location of this file or turn off
9+
// automatically serving support files with the
10+
// 'supportFile' configuration option.
11+
//
12+
// You can read more here:
13+
// https://on.cypress.io/configuration
14+
// ***********************************************************
15+
16+
// Import commands.js using ES2015 syntax:
17+
import './commands'
18+
19+
// Alternatively you can use CommonJS syntax:
20+
// require('./commands')
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// ***********************************************************
2+
// This example support/e2e.js is processed and
3+
// loaded automatically before your test files.
4+
//
5+
// This is a great place to put global configuration and
6+
// behavior that modifies Cypress.
7+
//
8+
// You can change the location of this file or turn off
9+
// automatically serving support files with the
10+
// 'supportFile' configuration option.
11+
//
12+
// You can read more here:
13+
// https://on.cypress.io/configuration
14+
// ***********************************************************
15+
16+
// Import commands.js using ES2015 syntax:
17+
import './commands'
18+
19+
// Alternatively you can use CommonJS syntax:
20+
// require('./commands')

packages/app/cypress/e2e/specs.cy.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,13 @@ describe('App: Specs', () => {
8181
'cypress_api',
8282
'files',
8383
'location',
84+
'misc',
8485
'navigation',
8586
'network_requests',
8687
'querying',
8788
'spies_stubs_clocks',
8889
'storage',
90+
'traversal',
8991
'utilities',
9092
'viewport',
9193
'waiting',
@@ -114,10 +116,7 @@ describe('App: Specs', () => {
114116
additionalIgnorePattern: [],
115117
})).map((spec) => spec.relative)
116118

117-
// Validate that all expected paths have been generated within the data context
118-
expect(generatedSpecPaths.filter((path) => {
119-
return options.expectedScaffoldPathsForPlatform.includes(path)
120-
})).to.have.lengthOf(options.expectedScaffoldPathsForPlatform.length)
119+
expect(generatedSpecPaths).to.include.members(options.expectedScaffoldPathsForPlatform)
121120
}, { expectedScaffoldPathsForPlatform })
122121

123122
// cy.percySnapshot() // TODO: restore when Percy CSS is fixed. See https://github.com/cypress-io/cypress/issues/23435

packages/app/src/specs/generators/scaffold/ScaffoldGeneratorStepOne.vue

+5-5
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656

5757
<script lang="ts" setup>
5858
import { gql, useMutation } from '@urql/vue'
59-
import { ScaffoldGeneratorStepOne_ScaffoldIntegrationDocument } from '../../../generated/graphql'
59+
import { ScaffoldGeneratorStepOne_E2eExamplesDocument } from '../../../generated/graphql'
6060
import { computed, onMounted } from 'vue'
6161
import { buildSpecTree } from '../../../specs/tree/useCollapsibleTree'
6262
import { useCollapsibleTree } from '../../tree/useCollapsibleTree'
@@ -68,8 +68,8 @@ import type { FoundSpec } from '@packages/types/src'
6868
const { t } = useI18n()
6969
7070
gql`
71-
mutation ScaffoldGeneratorStepOne_scaffoldIntegration {
72-
scaffoldIntegration {
71+
mutation ScaffoldGeneratorStepOne_e2eExamples {
72+
e2eExamples {
7373
file {
7474
id
7575
absolute
@@ -89,15 +89,15 @@ const emits = defineEmits<{
8989
(event: 'close'): void
9090
}>()
9191
92-
const mutation = useMutation(ScaffoldGeneratorStepOne_ScaffoldIntegrationDocument)
92+
const mutation = useMutation(ScaffoldGeneratorStepOne_E2eExamplesDocument)
9393
9494
onMounted(async () => {
9595
emits('update:title', t('createSpec.e2e.importFromScaffold.specsAddingHeader'))
9696
await mutation.executeMutation({})
9797
emits('update:title', t('createSpec.e2e.importFromScaffold.specsAddedHeader'))
9898
})
9999
100-
const scaffoldedFiles = computed(() => mutation.data.value?.scaffoldIntegration || [])
100+
const scaffoldedFiles = computed(() => mutation.data.value?.e2eExamples || [])
101101
const specTree = computed(() => {
102102
const files: FoundSpec[] = scaffoldedFiles.value.map((res) => {
103103
return {

packages/data-context/src/actions/CodegenActions.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,13 @@ export class CodegenActions {
129129
return path.join(projectRoot, 'cypress', 'e2e')
130130
}
131131

132-
async scaffoldIntegration (): Promise<NexusGenObjects['ScaffoldedFile'][]> {
132+
async e2eExamples (): Promise<NexusGenObjects['ScaffoldedFile'][]> {
133133
const projectRoot = this.ctx.currentProject
134134

135135
assert(projectRoot, `Cannot create spec without currentProject.`)
136136

137137
const results = await codeGenerator(
138-
{ templateDir: templates['scaffoldIntegration'], target: this.defaultE2EPath },
138+
{ templateDir: templates['e2eExamples'], target: this.defaultE2EPath },
139139
{},
140140
)
141141

packages/data-context/src/actions/ProjectActions.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ export class ProjectActions {
415415

416416
switch (this.ctx.coreData.currentTestingType) {
417417
case 'e2e':
418-
return hasNonExampleSpec(templates.scaffoldIntegration, specs)
418+
return hasNonExampleSpec(templates.e2eExamples, specs)
419419
case 'component':
420420
return specs.length > 0
421421
case null:

packages/data-context/src/codegen/templates.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ export default {
88
vueComponent: getPath('./templates/vue-component'),
99
componentEmpty: getPath('./templates/empty-component'),
1010
e2e: getPath('./templates/empty-e2e'),
11-
scaffoldIntegration: cypressEx.getPathToE2E(),
11+
e2eExamples: cypressEx.getPathToE2E(),
1212
} as const

packages/data-context/test/unit/codegen/code-generator.spec.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -319,10 +319,10 @@ describe('code-generator', () => {
319319
expect(() => babelParse(fileContent)).not.throw()
320320
})
321321

322-
it('should generate from scaffoldIntegration', async () => {
322+
it('should generate from e2eExamples', async () => {
323323
const target = path.join(tmpPath, 'scaffold-integration')
324324
const action: Action = {
325-
templateDir: templates.scaffoldIntegration,
325+
templateDir: templates.e2eExamples,
326326
target,
327327
}
328328

@@ -368,12 +368,12 @@ describe('code-generator', () => {
368368
it('should return true after adding new spec file', async () => {
369369
const target = path.join(tmpPath, 'spec-check')
370370

371-
const checkBeforeScaffolding = await hasNonExampleSpec(templates.scaffoldIntegration, [])
371+
const checkBeforeScaffolding = await hasNonExampleSpec(templates.e2eExamples, [])
372372

373373
expect(checkBeforeScaffolding, 'expected having no spec files to show no non-example specs').to.be.false
374374

375375
const scaffoldExamplesAction: Action = {
376-
templateDir: templates.scaffoldIntegration,
376+
templateDir: templates.e2eExamples,
377377
target,
378378
}
379379

@@ -389,7 +389,7 @@ describe('code-generator', () => {
389389

390390
const specs = addTemplatesAsSpecs(scaffoldResults)
391391

392-
const checkAfterScaffolding = await hasNonExampleSpec(templates.scaffoldIntegration, specs)
392+
const checkAfterScaffolding = await hasNonExampleSpec(templates.e2eExamples, specs)
393393

394394
expect(checkAfterScaffolding, 'expected only having template files to show no non-example specs').to.be.false
395395

@@ -404,7 +404,7 @@ describe('code-generator', () => {
404404

405405
const specsWithGenerated = [...specs, ...addTemplatesAsSpecs(generatedTest)]
406406

407-
const checkAfterTemplate = await hasNonExampleSpec(templates.scaffoldIntegration, specsWithGenerated)
407+
const checkAfterTemplate = await hasNonExampleSpec(templates.e2eExamples, specsWithGenerated)
408408

409409
expect(checkAfterTemplate, 'expected check after adding a new spec to indicate there are now non-example specs').to.be.true
410410
})

packages/errors/__snapshot-html__/EXPERIMENTAL_USE_DEFAULT_DOCUMENT_DOMAIN_E2E_ONLY.html

+45
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/example/README.md

+14-11
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,30 @@
1+
# Example
12

2-
## Scaffold config files
3+
This package is responsible for copying the `cypress/e2e` and `app` files from [`cypress-example-kitchensink`](https://github.com/cypress-io/cypress-example-kitchensink) into the cypress repository.
34

4-
The `cypress/plugins/index.js`, `cypress/support/*` and `cypress/tsconfig.json` from this package are used for user scaffolding in `packages/server` and `npm/create-cypress-tests`. This configuration files are by default injected when user instals Cypress.
5+
The `cypress/e2e` tests, pulled into this package from the [kitchen sink app](https://github.com/cypress-io/cypress-example-kitchensink), are used for scaffolding user's e2e tests in `packages/data-context` and in `npm/create-cypress-tests`.
56

6-
## Examples
7+
The `app` content, pulled into this package from the [kitchen sink app](https://github.com/cypress-io/cypress-example-kitchensink), is published to `cypress-io/cypress` repository's Github page, [https://example.cypress.io](https://example.cypress.io).
78

8-
This repo contains the source code for pushing out [https://example.cypress.io](https://example.cypress.io).
9+
## Updating Content
910

10-
The actual example repo you're probably looking for is [the kitchen sink app here](https://github.com/cypress-io/cypress-example-kitchensink).
11-
12-
**THERE'S LIKELY NO REASON YOU NEED TO EDIT ANY OF THE CODE ON THIS REPO.**
11+
**THERE'S LIKELY NO REASON YOU NEED TO EDIT ANY OF THE CODE IN THIS PACKAGE.**
1312

1413
- Want to edit the `example` tests? -> edit it [here](https://github.com/cypress-io/cypress-example-kitchensink/blob/master/cypress/e2e) instead.
1514
- Want to edit the actual [https://example.cypress.io](https://example.cypress.io) website? edit it [here](https://github.com/cypress-io/cypress-example-kitchensink/tree/master/app) instead.
1615

17-
## Updating the `example` app
16+
## Major Version Bumps of Cypress
17+
18+
If any of the breaking changes in the next major release requires updates to Cypress commands or APIs, verify the site content in `cypress-example-kitchensink` is up-to-date and that all examples that will be scaffolded can successfully run with the breaking change.
1819

19-
After [releasing a new version](https://github.com/cypress-io/cypress-example-kitchensink/blob/master/CONTRIBUTING.md#deployment) on the [`cypress-example-kitchen-sink` repo](https://github.com/cypress-io/cypress-example-kitchensink/tree/master/cypress/e2e/2-advanced-examples), you now want to update the `example`'s dependency to match the newly released version.
20+
## Using a new version of `cypress-example-kitchen-sink`
21+
22+
When a commit is merged into `master`, a new version of the [`cypress-example-kitchen-sink` repo](https://github.com/cypress-io/cypress-example-kitchensink/tree/master/cypress/e2e/2-advanced-examples) is released [automatically to npm](https://github.com/cypress-io/cypress-example-kitchensink/blob/master/CONTRIBUTING.md#deployment). When this happens, you will need to update the `example`'s dependency to match the newly released version.
2023

2124
1. Bump the `cypress-example-kitchensink` `devDependency` within this package's [`package.json`](https://github.com/cypress-io/cypress/blob/develop/packages/example/package.json).
2225

2326
2. Run `yarn` and `yarn workspace @packages/example` to build the app and spec files.
24-
CONTRIBUTING
27+
2528
3. Create a new pull-request following this repo's [pull request instructions](CONTRIBUTING.md#pull-requests).
2629

2730
## Building
@@ -32,7 +35,7 @@ After running `yarn` you must build the app + spec files.
3235
yarn workspace @packages/example build
3336
```
3437

35-
This copies the src files from [`cypress-example-kitchensink`](https://github.com/cypress-io/cypress-example-kitchensink), modifies them to point to `https://example.cypress.io` and creates the `example` tests.
38+
This copies the `cypress/e2e` and files from [`cypress-example-kitchensink`](https://github.com/cypress-io/cypress-example-kitchensink), modifies them to point to `https://example.cypress.io` and creates the `example` tests.
3639

3740
## Deploying
3841

packages/example/bin/build.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
11
#!/usr/bin/env node
22

3+
/* eslint-disable no-console */
4+
35
const resolvePkg = require('resolve-pkg')
46
const { join } = require('path')
57
const fs = require('fs-extra')
68
const path = require('path')
7-
const glob = require('glob')
8-
const util = require('util')
99
const childProcess = require('child_process')
1010

1111
const EXAMPLE_DIR = path.join(__dirname, '..')
12-
const globAsync = util.promisify(glob)
1312

14-
async function build() {
13+
async function build () {
1514
await Promise.all([
1615
fs.remove(path.join(EXAMPLE_DIR, 'app')),
17-
fs.remove(path.join(EXAMPLE_DIR, 'cypress'))
16+
fs.remove(path.join(EXAMPLE_DIR, 'cypress')),
1817
])
18+
1919
await Promise.all([
2020
fs.copy(join(resolvePkg('cypress-example-kitchensink'), 'app'), path.join(EXAMPLE_DIR, 'app')),
2121
fs.copy(join(resolvePkg('cypress-example-kitchensink'), 'cypress'), path.join(EXAMPLE_DIR, 'cypress')),
2222
])
23+
2324
childProcess.execSync('node ./bin/convert.js', {
2425
cwd: EXAMPLE_DIR,
25-
stdio: 'inherit'
26+
stdio: 'inherit',
2627
})
2728
}
2829

packages/example/cypress.config.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
module.exports = {
2-
"projectId": "2pz86o"
2+
'projectId': '2pz86o',
33
}
4-

packages/example/cypress/plugins/index.js

-22
This file was deleted.

packages/example/gulpfile.js

-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const gulp = require('gulp')
2-
const ghPages = require('gulp-gh-pages')
32
const gulpClean = require('gulp-clean')
43
const RevAll = require('gulp-rev-all')
54

@@ -26,13 +25,6 @@ const clean = () => {
2625
.pipe(gulpClean())
2726
}
2827

29-
const pushGhPages = () => {
30-
return gulp.src('build/**/*')
31-
.pipe(ghPages())
32-
}
33-
3428
const build = gulp.series(clean, gulp.parallel(assets, cname))
3529

3630
exports.build = build
37-
38-
exports.deploy = gulp.series(build, pushGhPages)

packages/example/index.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { default } from './lib/example'
1+
export { default } from './lib/example'

packages/example/lib/example.d.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
declare const example: {
2-
getPathToExamples(): Promise<string[]>;
3-
getPathToE2E(): string;
4-
getPathToPlugins(): string;
5-
getPathToTsConfig(): string;
6-
getPathToFixture(): string;
2+
getPathToE2E(): string
73
}
84

9-
export default example;
5+
export default example

0 commit comments

Comments
 (0)