Skip to content

Commit

Permalink
update project
Browse files Browse the repository at this point in the history
  • Loading branch information
lmiller1990 committed Feb 28, 2023
1 parent e9a79ac commit f716383
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 0 deletions.
53 changes: 53 additions & 0 deletions packages/launchpad/cypress/e2e/migration.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,59 @@ describe('Full migration flow for each project', { retries: { openMode: 0, runMo
checkOutcome()
})

it('completes journey for migration-e2e-custom-test-files', () => {
const project = 'migration-e2e-custom-test-files-array'

startMigrationFor(project)
// default integration but custom testFiles
// can rename integration->e2e
cy.get(renameAutoStep).should('exist')
// no CT
cy.get(renameManualStep).should('not.exist')
// supportFile is false - cannot migrate
cy.get(renameSupportStep).should('exist')
cy.get(setupComponentStep).should('not.exist')
cy.get(configFileStep).should('exist')

cy.scaffoldProject(project)
cy.openProject(project)
cy.visitLaunchpad()

// default testFiles but custom integration - can rename automatically
cy.get(renameAutoStep).should('exist')
// no CT
cy.get(renameManualStep).should('not.exist')
// supportFile is false - cannot migrate
cy.get(renameSupportStep).should('exist')
cy.get(setupComponentStep).should('not.exist')
cy.get(configFileStep).should('exist')

// Migration workflow
// before auto migration
cy.contains('cypress/integration/basic.test.js')
cy.contains('cypress/integration/basic.spec.js')

// after auto migration
cy.contains('cypress/e2e/basic.test.js')
cy.contains('cypress/e2e/basic.spec.js')

runAutoRename()

cy.withRetryableCtx(async (ctx) => {
const specs = ['cypress/e2e/basic.test.js', 'cypress/e2e/basic.spec.js']

for (const spec of specs) {
const stats = await ctx.file.checkIfFileExists(ctx.path.join(spec))

expect(stats).to.not.be.null
}
})

renameSupport()
migrateAndVerifyConfig()
checkOutcome()
})

it('completes journey for migration-e2e-defaults', () => {
startMigrationFor('migration-e2e-defaults')
// defaults, rename all the things
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
## Migration E2E Custom testFiles

An e2e project with a custom testFiles but default integrationFolder. We won't rename the specs, but we will rename `integration` to `e2e`. `testFiles` is an *array* of globs.

The following migration steps will be used during this migration:

- [x] automatic file rename
- [ ] manual file rename
- [x] rename support
- [x] update config file
- [ ] setup component testing

## Automatic Migration

Unless the user skips this step, after this step, the filesystem will be:

| Before | After|
|---|---|
| `integration/basic.test.js` | `e2e/basic.test.js` |
| `integration/basic.spec.js` | `e2e/basic.spec.js` |

## Manual Files

This step is not used.

## Rename supportFile

The project has a default support file, `cypress/support/index.js`. We can rename it for them to `cypress/support/e2e.js`.

| Before | After|
|---|---|
| `cypress/support/index.js` | `cypress/support/e2e.js` |

## Update Config

The expected output is in [`expected-cypress.config.js`](./expected-cypress.config.js).
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"testFiles": [
"**/*.test.js",
"**/*.spec.js"
]
}
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const { defineConfig } = require('cypress')

module.exports = defineConfig({
e2e: {
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
setupNodeEvents (on, config) {
return require('./cypress/plugins/index.js')(on, config)
},
specPattern: ['cypress/e2e/**/*.test.js', 'cypress/e2e/**/*.spec.js'],
},
})

0 comments on commit f716383

Please sign in to comment.