Skip to content

Commit

Permalink
fix: upgrade plugin for newer cypress versions (#533)
Browse files Browse the repository at this point in the history
* update deps, migrate cypress config

* update deps, migrate cypress config

* fix functionality

* use import instead of require

* add types

* add types

* update readme

* add .d.ts to files

* add wrongly ignored js spec files and cypress-config

---------

Co-authored-by: Simon Fischer <[email protected]>
  • Loading branch information
SimonFischer04 and Simon Fischer authored May 9, 2024
1 parent 111a3fd commit 9f410ee
Show file tree
Hide file tree
Showing 12 changed files with 6,634 additions and 3,957 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
.idea
node_modules/
cypress/screenshots
cypress/videos
*.js
!cypress/**
*.d.ts
30 changes: 19 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,38 @@
npm i -D cypress-skip-and-only-ui
```

Require from your `cypress/support/index.js`
Import from your `cypress/support/e2e.js`

```js
require('cypress-skip-and-only-ui/support')
import 'cypress-skip-and-only-ui/support';
```

Require and register task from `cypress/plugins/index.js`
Import and register task from `cypress.config.ts` / `cypress.config.js`

```js
const task = require('cypress-skip-and-only-ui/task')
module.exports = (on, config) => {
on('task', task)
}
import { defineConfig } from 'cypress'
import skipAndOnlyUiTasks from 'cypress-skip-and-only-ui/task';

export default defineConfig({
e2e: {
setupNodeEvents(on, config) {
on('task', skipAndOnlyUiTasks)
}
}
});
```

Note: if you have other tasks already, just merge the objects before registering

```js
const otherTask = { ... }
const task = require('cypress-skip-and-only-ui/task')
import { defineConfig } from 'cypress'
import skipAndOnlyUiTasks from 'cypress-skip-and-only-ui/task';

const otherTasks = [{ ... }]
module.exports = (on, config) => {
on('task', {
otherTask,
task
...otherTasks,
...skipAndOnlyUiTasks
})
}
```
Expand Down
10 changes: 10 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { defineConfig } from 'cypress'
import task from './task';

export default defineConfig({
e2e: {
setupNodeEvents(on, config) {
on('task', task)
}
}
});
1 change: 0 additions & 1 deletion cypress.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ it('works with imports', () => {

it('works with imports 2', () => {
expect(foo).to.be.a('string')
})
})
2 changes: 1 addition & 1 deletion cypress/integration/spec.js → cypress/e2e/spec.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ describe('several tests together', () => {
context('inner', () => {
it('has deep test', () => {})
})
})
})
9 changes: 0 additions & 9 deletions cypress/plugins/index.js

This file was deleted.

7 changes: 3 additions & 4 deletions cypress/support/index.js → cypress/support/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands'

require('../../support')

import './commands';
// Alternatively you can use CommonJS syntax:
// require('./commands')

import '../../support';
Loading

0 comments on commit 9f410ee

Please sign in to comment.