-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from Lakitna/attribute-command-retry-fix
Attribute command retry fix
- Loading branch information
Showing
45 changed files
with
8,552 additions
and
4,184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Editor configuration, see https://editorconfig.org | ||
# Used by various tools. Among which: VS Code, Prettier | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
indent_style = space | ||
indent_size = 4 | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
end_of_line = lf | ||
|
||
[*.ts] | ||
quote_type = single | ||
|
||
[*.js] | ||
quote_type = single | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[*.yaml] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[{package.json,package-lock.json}] | ||
indent_style = space | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,55 @@ | ||
/* eslint-disable sonarjs/no-duplicate-string */ | ||
module.exports = { | ||
"plugins": [ | ||
"sonarjs", | ||
"cypress", | ||
], | ||
"extends": [ | ||
"google", | ||
"plugin:sonarjs/recommended", | ||
"plugin:cypress/recommended", | ||
], | ||
"parserOptions": { | ||
"sourceType": "module", | ||
"ecmaVersion": 8 | ||
plugins: ['sonarjs', 'cypress'], | ||
extends: ['google', 'plugin:sonarjs/recommended', 'plugin:cypress/recommended'], | ||
parserOptions: { | ||
sourceType: 'module', | ||
ecmaVersion: 8, | ||
}, | ||
"env": { | ||
"node": true, | ||
"es6": true, | ||
env: { | ||
node: true, | ||
es6: true, | ||
}, | ||
"rules": { | ||
"indent": [ | ||
"error", | ||
4, | ||
], | ||
"max-len": [ | ||
"error", | ||
100, | ||
rules: { | ||
'indent': ['error', 4], | ||
'max-len': ['error', 100], | ||
'linebreak-style': 'off', | ||
'no-multi-spaces': [ | ||
'error', | ||
{ | ||
exceptions: { | ||
VariableDeclarator: true, | ||
}, | ||
}, | ||
], | ||
"linebreak-style": "off", | ||
"no-multi-spaces": [ | ||
"error", { | ||
"exceptions": { | ||
"VariableDeclarator": true, | ||
} | ||
} | ||
'object-curly-spacing': ['error', 'always'], | ||
'comma-dangle': [ | ||
'error', | ||
{ | ||
arrays: 'always-multiline', | ||
objects: 'always-multiline', | ||
imports: 'always-multiline', | ||
exports: 'always-multiline', | ||
functions: 'never', | ||
}, | ||
], | ||
"brace-style": [ | ||
"error", | ||
"stroustrup", | ||
'space-before-function-paren': [ | ||
'error', | ||
{ | ||
anonymous: 'always', | ||
named: 'never', | ||
asyncArrow: 'always', | ||
}, | ||
], | ||
"object-curly-spacing": ["error", "always"], | ||
"operator-linebreak": ["error", "before"], | ||
}, | ||
"overrides": [{ | ||
"files": ["lib/**/*"], | ||
"rules": { | ||
// This is fine as long as you know what you're doing | ||
"cypress/no-assigning-return-values": "warn", | ||
} | ||
}, | ||
{ | ||
"files": ["cypress/integration/**/*"], | ||
"rules": { | ||
"sonarjs/no-identical-functions": "warn", | ||
"sonarjs/no-duplicate-string": ["warn", 5], | ||
"no-invalid-this": "off", | ||
overrides: [ | ||
{ | ||
files: ['cypress/integration/**/*'], | ||
rules: { | ||
'sonarjs/no-identical-functions': 'warn', | ||
'sonarjs/no-duplicate-string': ['warn', 5], | ||
'no-invalid-this': 'off', | ||
}, | ||
}, | ||
}], | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions | ||
|
||
name: Node.js CI | ||
|
||
on: | ||
push: | ||
branches: [develop] | ||
pull_request: | ||
branches: [develop] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/ | ||
node-version: [10.x, 14.x, 16.x] | ||
|
||
# Runs with `package.json` use the version defined in `~/package.lock.json`. | ||
cypress-version: [package.json, 8.2, 6] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: 'npm' | ||
- run: npm ci | ||
- if: ${{ matrix.cypress-version != 'package.json' }} | ||
run: npm install cypress@${{ matrix.cypress-version }} | ||
- run: npm run lint | ||
- run: npm run test:source | ||
- run: npm run bundle | ||
- run: npm run test:bundle |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"singleQuote": true, | ||
"semi": true, | ||
"bracketSpacing": true, | ||
"trailingComma": "es5", | ||
"proseWrap": "always", | ||
"printWidth": 100, | ||
"quoteProps": "consistent" | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"recommendations": ["esbenp.prettier-vscode"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"editor.formatOnSave": true, | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
## 2.0.0 - 2021-09-13 | ||
|
||
### Breaking changes | ||
|
||
#### Whitespace handling for zero-width whitespace in `.text()` and `.attribute()` | ||
|
||
Whitespace handling in `.text()` and `.attribute()` has been changed to no longer consider | ||
zero-width whitespace to be whitespace in modes `{whitespace: 'simplify'}` and | ||
`{whitespace: 'keep-newline'}`. Mode `{whitespace: 'keep'}` has not changed. | ||
|
||
<!-- prettier-ignore --> | ||
```html | ||
<div>super\u200Bcalifragilistic\u200Bexpialidocious</div> | ||
``` | ||
|
||
```javascript | ||
// Old situation | ||
cy.get('div').text().should('equal', 'super califragilistic expialidocious'); | ||
``` | ||
|
||
```javascript | ||
// New situation | ||
cy.get('div').text().should('equal', 'supercalifragilisticexpialidocious'); | ||
``` | ||
|
||
When using `.text()` on elements containing the `<wbr>` tag: `<wbr>` is now considered a zero-width | ||
space and will thus be removed with whitespace `simplify` and `keep-newline` as described above. | ||
|
||
<!-- prettier-ignore --> | ||
```html | ||
<div>super<wbr>califragilistic<wbr>expialidocious</div> | ||
``` | ||
|
||
```javascript | ||
// Old situation | ||
cy.get('div').text().should('equal', 'super califragilistic expialidocious'); | ||
``` | ||
|
||
```javascript | ||
// New situation | ||
cy.get('div').text().should('equal', 'supercalifragilisticexpialidocious'); | ||
``` | ||
|
||
#### Output order of `.text()` | ||
|
||
When using `.text({ depth: Number })` the order of texts has been changed to better reflect what the | ||
user sees. It will now first traverse all the way to the deepest point, before going sideways. This | ||
will make `.text()` behave much better with inline styling and links. | ||
|
||
<!-- prettier-ignore --> | ||
```html | ||
<div class="parent"> | ||
parent div top | ||
<div> | ||
child div | ||
</div> | ||
parent div middle | ||
<div> | ||
second-child div | ||
</div> | ||
parent div bottom | ||
</div> | ||
``` | ||
|
||
```javascript | ||
// Old situation | ||
// Note how the first part of the string is the various parts of `div.parent` | ||
cy.get('parent') | ||
.text({ depth: 1 }) | ||
.should('equal', 'parent div top parent div middle parent div bottom child div second-child div'); | ||
``` | ||
|
||
```javascript | ||
// New situation | ||
cy.get('div') | ||
.text({ depth: 1 }) | ||
.should('equal', 'parent div top child div parent div middle second-child div parent div bottom'); | ||
``` | ||
|
||
Inline text formatting: | ||
|
||
<!-- prettier-ignore --> | ||
```html | ||
<div> | ||
Text with <b>some</b> styling and <a href="...">a link</a>. | ||
</div> | ||
``` | ||
|
||
```javascript | ||
// Old situation | ||
cy.get('div').text({ depth: 1 }).should('equal', 'Text with styling and . some a link'); | ||
``` | ||
|
||
```javascript | ||
// New situation | ||
cy.get('div').text({ depth: 1 }).should('equal', 'Text with some styling and a link.'); | ||
``` | ||
|
||
#### Stricter types | ||
|
||
Types have been made stricter for `.attribute()`, `text()`, and `.to()`. This is a great improvement | ||
for TypeScript users as it reduces any manual casting. It allows for things like: | ||
|
||
```typescript | ||
cy.get('div') | ||
.text() // yields type 'string | string[]' | ||
.to('array') // yields type 'string[]' | ||
.then((texts: string[]) => ...); | ||
``` | ||
|
||
```typescript | ||
cy.get('div') | ||
.attribute('class') // yields type 'string | string[]' | ||
.to('array') // yields type 'string[]' | ||
.then((texts: string[]) => ...); | ||
``` | ||
|
||
### Fixes | ||
|
||
- Support for Cypress 8.3.0 and above. There was a change in an internal API used for the | ||
`.attribute()` command. This internal API allows us to do some complex stuff with | ||
`{strict: true}`. The fix does not impact versions <= 8.2.0. See #60 for details. | ||
|
||
- `.attribute()` would not work properly in situations where it finds one attribute with a string | ||
length longer than the number of elements. For example: | ||
|
||
<!-- prettier-ignore --> | ||
```html | ||
<div data-foo="hello"></div> | ||
<div></div> | ||
<div></div> | ||
``` | ||
|
||
```javascript | ||
cy.get('div').attribute('data-foo'); // Throws error because `hello`.length > $elements.length | ||
``` | ||
|
||
This change also prompted some refactoring. | ||
|
||
- Updated docs based on changed made upstream in the Cypress docs. | ||
|
||
- Added config for Prettier/editorconfig and Eslint rules to match them. Reformatted a lot of files | ||
because of this. | ||
|
||
- Moved CI from Travis to Github. Now tests on multiple versions of NodeJS and multiple versions of | ||
Cypress. | ||
|
||
- Updated a lot of dependencies. It was over due. | ||
|
||
- Switched use of `path` to `path-browserify` to reduce config overhead for TypeScript users. |
Oops, something went wrong.