Skip to content

Commit 45a4cac

Browse files
authored
Cypress 10+ support (#65)
Long-awaited Cypress 10+ Support for cy.tab() - remove Ally.js dependency (abandoned) - closes #59 - closes #37 - fix focus randomly being lost due (due to ally.js) - closes #46 - upgrade to Cypress 10+, with new compatible type definitions - closes #6 - closes #40 - fix tabbing from focusable elements - fixes #18 - subsumes #24 - follow subject changes in Cypress command chain / events sent in proper order before focus change - closes #47 - fix hanging tests when used with cy.clock - closes #42
1 parent 61db462 commit 45a4cac

34 files changed

Lines changed: 2136 additions & 5738 deletions

.eslintignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

.eslintrc.json

Lines changed: 0 additions & 9 deletions
This file was deleted.

.github/workflows/nodejs.yml

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,25 @@ on: [push]
44

55
jobs:
66
test-e2e:
7-
runs-on: ubuntu-16.04
8-
container:
9-
image: cypress/browsers:node12.16.1-chrome80-ff73
10-
options: --user 1001
11-
7+
runs-on: ubuntu-latest
128
strategy:
139
matrix:
14-
cypress-version: ["current", "current-firefox", 3.8.3, 3.4.1]
10+
cypress-version: ['10.11.0', '15.1.0']
1511

1612
steps:
17-
- uses: actions/checkout@v1
18-
- uses: actions/setup-node@v1
13+
- uses: actions/checkout@v4
14+
- uses: actions/setup-node@v4
1915
with:
20-
node-version: "12.x"
16+
node-version: '20'
17+
cache: yarn
2118

2219
- name: install
23-
run: |
24-
yarn install --frozen-lockfile
25-
26-
- name: print-info
27-
run: |
28-
firefox --version
20+
run: yarn install --frozen-lockfile
2921

30-
- name: maybe-install
31-
run: |
32-
firefox --version
33-
[[ current-firefox =~ current ]] || yarn add -D cypress@current-firefox
34-
shell: bash
22+
- name: install Cypress ${{ matrix.cypress-version }}
23+
run: yarn add -D cypress@${{ matrix.cypress-version }}
3524

36-
- name: test
37-
run: |
38-
yarn test-e2e $([[ ${{ matrix.cypress-version }} =~ 'firefox' ]] && echo '--browser firefox')
25+
- name: test against Cypress ${{ matrix.cypress-version }}
26+
run: yarn test-e2e
3927
env:
4028
CI: true
41-
shell: bash

.github/workflows/release.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: read
10+
id-token: write
11+
12+
jobs:
13+
publish:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- uses: actions/setup-node@v4
22+
with:
23+
node-version: '22.14.0'
24+
registry-url: 'https://registry.npmjs.org'
25+
cache: yarn
26+
27+
- name: Install dependencies
28+
run: yarn install --frozen-lockfile
29+
30+
- name: Verify tag matches package version
31+
shell: bash
32+
run: |
33+
PACKAGE_VERSION="$(node -p "require('./package.json').version")"
34+
TAG_VERSION="${GITHUB_REF_NAME#v}"
35+
36+
if [[ "${PACKAGE_VERSION}" != "${TAG_VERSION}" ]]; then
37+
echo "Tag ${GITHUB_REF_NAME} does not match package.json version ${PACKAGE_VERSION}" >&2
38+
exit 1
39+
fi
40+
41+
- name: Check package contents
42+
run: npm pack --dry-run
43+
44+
- name: Publish to npm
45+
run: npm publish --provenance --access public

.prettierignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
node_modules
2+
coverage
3+
dist
4+
cypress/videos
5+
cypress/screenshots
6+
cypress/fixtures
7+
docs/*.gif
8+
docs/*.png
9+
yarn.lock
10+
package-lock.json

.prettierrc.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"singleQuote": true,
3+
"semi": false
4+
}

.vscode/settings.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
{
2222
"language": "json",
2323
"autoFix": true
24-
},
24+
}
2525
],
2626
"editor.codeActionsOnSave": {
27-
"source.fixAll.eslint": true
28-
},
27+
"source.fixAll.eslint": "explicit"
28+
}
2929
}

README.md

Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,58 @@
1-
21
<div align="center">
3-
<!-- <img src="docs/readme-logo.png"> -->
4-
<h1>cypress-plugin-tab <kbd>beta</kbd></h1>
2+
<h1>cypress-plugin-tab</h1>
53
<a href="https://www.npmjs.com/package/cypress-plugin-tab"><img src="https://img.shields.io/npm/v/cypress-plugin-tab.svg?style=flat"></a>
64
<a href="https://www.npmjs.com/package/cypress-plugin-tab"><img src="https://img.shields.io/npm/dt/cypress-plugin-tab.svg"></a>
7-
<a href="https://github.com/bkucera/cypress-plugin-tab/blob/master/LICENSE"><img src="https://img.shields.io/github/license/bkucera/cypress-plugin-tab.svg"></a>
5+
<a href="https://github.com/kuceb/cypress-plugin-tab/blob/master/LICENSE"><img src="https://img.shields.io/github/license/kuceb/cypress-plugin-tab.svg"></a>
86
<p>A Cypress plugin to add a tab command</p>
97

108
</div>
119

12-
> :warning: this module is in beta, and might cause some strange failures. Please report bugs in the issues of this repo.
13-
14-
> Note: [please refer to this issue for updates about official cypress tab support](https://github.com/cypress-io/cypress/issues/299)
15-
1610
![](docs/readme-screenshot.png)
1711
![](docs/readme-demo.gif)
1812

1913
### Installation
2014

21-
Add the plugin to `devDependencies`
15+
This package supports Cypress 10+.
16+
17+
1. Install the plugin:
18+
2219
```bash
2320
npm install -D cypress-plugin-tab
2421
```
2522

26-
At the top of **`cypress/support/index.js`**:
23+
2. Load it from your Cypress support file at **`cypress/support/e2e.js`**:
24+
2725
```js
2826
require('cypress-plugin-tab')
2927
```
3028

29+
If your support file is TypeScript, use:
30+
31+
```ts
32+
import 'cypress-plugin-tab'
33+
```
34+
35+
3. Make sure your Cypress config points at that support file. Example **`cypress.config.js`**:
36+
37+
```js
38+
const { defineConfig } = require('cypress')
39+
40+
module.exports = defineConfig({
41+
e2e: {
42+
supportFile: 'cypress/support/e2e.js',
43+
},
44+
})
45+
```
46+
47+
4. If you use TypeScript and want the custom command typed in editors, add the package to your Cypress tsconfig:
48+
49+
```json
50+
{
51+
"compilerOptions": {
52+
"types": ["cypress", "cypress-plugin-tab"]
53+
}
54+
}
55+
```
3156

3257
### Usage
3358

@@ -36,19 +61,22 @@ require('cypress-plugin-tab')
3661
- `.tab({ shift: true })` sends a shift-tab to the element
3762

3863
```js
39-
cy.get('input').type('foo').tab().type('bar') // type foo, then press tab, then type bar
40-
cy.get('body').tab() // tab into the first tabbable element on the page
41-
cy.focused().tab() // tab into the currently focused element
64+
cy.get('input').type('hello').tab().type('world') // type foo, then press tab, then type bar
65+
cy.get('body').tab() // tab into the first tabbable element on the page
66+
cy.focused().tab() // tab into the currently focused element
4267
```
4368

4469
shift+tab:
4570

4671
```js
4772
cy.get('input')
48-
.type('foop').tab()
49-
.type('bar').tab({ shift: true })
50-
.type('foo') // correct your mistake
73+
.type('hwllo')
74+
.tab()
75+
.type('world')
76+
.tab({ shift: true })
77+
.type('hello') // correct your mistake
5178
```
5279

5380
### License
81+
5482
[MIT](LICENSE)

RELEASE_NOTES.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Release Notes
2+
3+
## 2.0.0
4+
5+
This release updates `cypress-plugin-tab` for Cypress 10+ and drops support for older Cypress project layouts.
6+
7+
### Breaking Changes
8+
9+
- Dropped support for Cypress versions earlier than 10.
10+
- Consumers should use the Cypress 10+ project structure with `cypress.config.js` or `cypress.config.ts`.
11+
- Consumers should load the plugin from `cypress/support/e2e.js` instead of the legacy `cypress/support/index.js`.
12+
- The package now declares Cypress 10+ compatibility via `peerDependencies`.
13+
14+
### Added
15+
16+
- Cypress 10+ project configuration for this repo.
17+
- CI coverage for Cypress 10 and Cypress 15.
18+
- TypeScript compile-time tests for the custom `cy.tab()` command.
19+
- Regression coverage for tabbing out of programmatically focused `tabindex="-1"` elements.
20+
21+
### Fixed
22+
23+
- TypeScript declaration merging for `cy.tab()` in module-based TypeScript setups.
24+
- Tabbing behavior when focus starts on a focusable but non-tabbable element such as `tabindex="-1"`.
25+
26+
### Migration
27+
28+
Install the package:
29+
30+
```bash
31+
npm install -D cypress-plugin-tab
32+
```
33+
34+
Load it from `cypress/support/e2e.js`:
35+
36+
```js
37+
require('cypress-plugin-tab')
38+
```
39+
40+
If your Cypress support file is TypeScript:
41+
42+
```ts
43+
import 'cypress-plugin-tab'
44+
```
45+
46+
If you use TypeScript and want editor support for `cy.tab()`, include the package in your Cypress tsconfig:
47+
48+
```json
49+
{
50+
"compilerOptions": {
51+
"types": ["cypress", "cypress-plugin-tab"]
52+
}
53+
}
54+
```

circle.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)