Skip to content

Commit 0b5d0dd

Browse files
committed
fix: typings for older typescript
closes #167 Signed-off-by: Jakub Freisler <[email protected]>
1 parent db106b1 commit 0b5d0dd

32 files changed

+345
-219
lines changed

.eslintrc.js

+12-19
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,31 @@
11
module.exports = {
22
root: true,
3-
plugins: [
4-
'@typescript-eslint',
5-
'eslint-comments',
6-
"cypress"
7-
],
3+
plugins: ["@typescript-eslint", "eslint-comments", "cypress"],
84
env: {
95
es6: true,
106
node: true,
11-
'cypress/globals': true
7+
"cypress/globals": true,
128
},
139
extends: [
14-
'eslint:recommended',
15-
'plugin:@typescript-eslint/recommended',
16-
'plugin:eslint-comments/recommended',
17-
'prettier'
10+
"eslint:recommended",
11+
"plugin:@typescript-eslint/recommended",
12+
"plugin:eslint-comments/recommended",
13+
"prettier",
1814
],
1915
overrides: [
2016
{
21-
files: ['**.ts'],
22-
parser: '@typescript-eslint/parser',
17+
files: ["**.ts"],
18+
parser: "@typescript-eslint/parser",
2319
parserOptions: {
24-
sourceType: 'module',
25-
project: [
26-
'./tsconfig.json',
27-
'./packages/*/tsconfig.json',
28-
],
20+
sourceType: "module",
21+
project: ["./tsconfig.json", "./example/tsconfig.json"],
2922
tsconfigRootDir: __dirname,
3023
warnOnUnsupportedTypeScriptVersion: false,
3124
EXPERIMENTAL_useSourceOfProjectReferenceRedirect: true,
3225
},
3326
rules: {
34-
'@typescript-eslint/explicit-module-boundary-types': 'off'
35-
}
27+
"@typescript-eslint/explicit-module-boundary-types": "off",
28+
},
3629
},
3730
],
3831
};

.github/FUNDING.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
github: [FRSOURCE]
44
patreon: frsource
5-
custom: ['https://www.buymeacoffee.com/FRSOURCE']
5+
custom: ["https://www.buymeacoffee.com/FRSOURCE"]

.github/ISSUE_TEMPLATE/bug_report.md

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
---
22
name: Bug report
33
about: Create a report to help us improve
4-
title: ''
4+
title: ""
55
labels: bug
6-
assignees: ''
7-
6+
assignees: ""
87
---
98

109
**Describe the bug**
1110
A clear and concise description of what the bug is.
1211

1312
**To Reproduce**
1413
Steps to reproduce the behavior:
14+
1515
1. Go to '...'
1616
2. Click on '....'
1717
3. Scroll down to '....'
@@ -24,9 +24,10 @@ A clear and concise description of what you expected to happen.
2424
If applicable, add screenshots to help explain your problem.
2525

2626
**Please complete the following information:**
27-
- OS and version: [e.g. Windows 10 build. 19043.1319]
28-
- Browser and version [e.g. chrome 22]
29-
- Cypress version [e.g. 8.6.0]
27+
28+
- OS and version: [e.g. Windows 10 build. 19043.1319]
29+
- Browser and version [e.g. chrome 22]
30+
- Cypress version [e.g. 8.6.0]
3031

3132
**Additional context**
3233
Add any other context about the problem here.

.github/ISSUE_TEMPLATE/feature_request.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
---
22
name: Feature request
33
about: Suggest an idea for this project
4-
title: ''
4+
title: ""
55
labels: enhancement
6-
assignees: ''
7-
6+
assignees: ""
87
---
98

109
**Is your feature request related to a problem? Please describe.**

.github/workflows/ci.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: CI
1+
name: CI
22
on:
33
pull_request_target:
44
branches:
@@ -17,7 +17,7 @@ jobs:
1717
- uses: actions/checkout@v3
1818
- uses: actions/setup-node@v3
1919
with:
20-
node-version: '16.x'
20+
node-version: "16.x"
2121
- name: Remove git auth
2222
run: git config --unset http.https://github.com/.extraheader
2323
- name: Generate yarn cache-key
@@ -52,7 +52,7 @@ jobs:
5252
- uses: actions/checkout@v3
5353
- uses: actions/setup-node@v3
5454
with:
55-
node-version: '16.x'
55+
node-version: "16.x"
5656
- name: remove git auth
5757
run: git config --unset http.https://github.com/.extraheader
5858
- name: Configure Yarn cache
@@ -79,7 +79,7 @@ jobs:
7979
- uses: actions/checkout@v3
8080
- uses: actions/setup-node@v3
8181
with:
82-
node-version: '16.x'
82+
node-version: "16.x"
8383
- name: remove git auth
8484
run: git config --unset http.https://github.com/.extraheader
8585
- name: Configure Yarn cache
@@ -110,7 +110,7 @@ jobs:
110110
- uses: actions/checkout@v3
111111
- uses: actions/setup-node@v3
112112
with:
113-
node-version: '16.x'
113+
node-version: "16.x"
114114
- name: remove git auth
115115
run: git config --unset http.https://github.com/.extraheader
116116
- name: Configure Yarn cache
@@ -149,7 +149,7 @@ jobs:
149149
git config --global user.email "$(git --no-pager log --format=format:'%ae' -n 1)"
150150
- uses: actions/setup-node@v3
151151
with:
152-
node-version: '16.x'
152+
node-version: "16.x"
153153
- name: remove git auth
154154
run: git config --unset http.https://github.com/.extraheader
155155
- name: Configure Yarn cache

.prettierignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules
2+
dist
3+
coverage
4+
CHANGELOG.md
5+
.yarnrc.yml
6+
example/.yarnrc.yml
7+
.yarn

CONTRIBUTING.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Don’t hesitate to ask a question directly on the [discussions board](https://g
2929
- We have no preference about number of commits on the PR - they will be all squashed by GitHub while merging
3030

3131
- When creating a new feature/plugin/integration:
32+
3233
- Make sure the feature is covered by tests
3334
- Provide a meaningful description. In most cases it would make sens to first open a issue with a suggestion, discuss about it and have it approved before working on it
3435

@@ -40,12 +41,14 @@ Don’t hesitate to ask a question directly on the [discussions board](https://g
4041
## Development Setup
4142

4243
<!-- textlint-disable spelling -->
44+
4345
You will need [Node.js](https://nodejs.org/en/) **version 16+** and [yarn](https://yarnpkg.com/getting-started/install).
46+
4447
<!-- textlint-enable -->
4548

4649
After cloning the repository, run:
4750

48-
``` bash
51+
```bash
4952
yarn i # installs the project dependencies
5053
cd example && yarn i # install dependencies for example project (useful for testing)
5154
```
@@ -58,7 +61,7 @@ Commit messages should follow the [conventional commits v1.0.0](https://www.conv
5861

5962
When fired in the project root they will run corresponding actions in every nested package at once.
6063

61-
``` bash
64+
```bash
6265
# build the project for NPM and example usage
6366
$ yarn build
6467

README.md

+30-22
Original file line numberDiff line numberDiff line change
@@ -71,54 +71,63 @@ npm install --save-dev @frsource/cypress-plugin-visual-regression-diff
7171
Next, you need to import the library:
7272

7373
- first, in your support file (located by default in `cypress/support/index.js`):
74+
7475
```ts
7576
// typescript / ES6
76-
import '@frsource/cypress-plugin-visual-regression-diff';
77+
import "@frsource/cypress-plugin-visual-regression-diff";
7778

7879
// javascript
79-
require('@frsource/cypress-plugin-visual-regression-diff');
80+
require("@frsource/cypress-plugin-visual-regression-diff");
8081
```
8182

8283
- secondly:
8384
- (for Cypress 10.0+) in `cypress.config.js` (or `cypress.config.ts`):
85+
8486
```ts
8587
// typescript / ES6
86-
import { defineConfig } from 'cypress';
87-
import { initPlugin } from '@frsource/cypress-plugin-visual-regression-diff/plugins';
88+
import { defineConfig } from "cypress";
89+
import { initPlugin } from "@frsource/cypress-plugin-visual-regression-diff/plugins";
8890

8991
export default defineConfig({
9092
// initPlugin must be called in the section where it is used: e2e or component
9193
e2e: {
9294
setupNodeEvents(on, config) {
9395
initPlugin(on, config);
94-
}
96+
},
9597
},
9698
component: {
9799
setupNodeEvents(on, config) {
98100
initPlugin(on, config);
99-
}
100-
}
101+
},
102+
},
101103
});
102104
```
103-
- (for Cypress <10.0) in your plugins file (located by default in `cypress/plugins/index.js`):
105+
106+
- (for Cypress <10.0) in your plugins file (located by default in `cypress/plugins/index.js`):
107+
104108
```ts
105109
// typescript / ES6
106-
import { initPlugin } from '@frsource/cypress-plugin-visual-regression-diff/plugins';
110+
import { initPlugin } from "@frsource/cypress-plugin-visual-regression-diff/plugins";
107111

108-
export default function (on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions) {
112+
export default function (
113+
on: Cypress.PluginEvents,
114+
config: Cypress.PluginConfigOptions
115+
) {
109116
initPlugin(on, config);
110117

111118
return config;
112-
};
119+
}
113120

114121
// javascript
115-
const { initPlugin } = require('@frsource/cypress-plugin-visual-regression-diff/plugins');
122+
const {
123+
initPlugin,
124+
} = require("@frsource/cypress-plugin-visual-regression-diff/plugins");
116125

117126
module.exports = function (on, config) {
118127
initPlugin(on, config);
119128

120129
return config;
121-
}
130+
};
122131
```
123132

124133
That's it - now let's see how to use the library in [usage section](#usage).
@@ -128,7 +137,7 @@ That's it - now let's see how to use the library in [usage section](#usage).
128137
Once installed, the library might be used by writing in your test:
129138

130139
```ts
131-
cy.get('.an-element-of-your-choice').matchImage();
140+
cy.get(".an-element-of-your-choice").matchImage();
132141
```
133142

134143
Or, if you would like to make a screenshot of whole document:
@@ -184,7 +193,7 @@ cy.matchImage({
184193
// maximum threshold above which the test should fail
185194
// default: 0.01
186195
maxDiffThreshold: 0.1,
187-
// forces scale factor to be set as value "1"
196+
// forces scale factor to be set as value "1"
188197
// helps with screenshots being scaled 2x on high-density screens like Mac Retina
189198
// default: true
190199
forceDeviceScaleFactor: false,
@@ -206,16 +215,15 @@ npx cypress run --env "pluginVisualRegressionUpdateImages=true,pluginVisualRegre
206215

207216
```ts
208217
// cypress.config.ts
209-
import { defineConfig } from 'cypress';
218+
import { defineConfig } from "cypress";
210219

211220
export default defineConfig({
212221
env: {
213222
pluginVisualRegressionUpdateImages: true,
214-
pluginVisualRegressionDiffConfig: { threshold: 0.01 }
215-
}
216-
})
223+
pluginVisualRegressionDiffConfig: { threshold: 0.01 },
224+
},
225+
});
217226
{
218-
219227
}
220228
```
221229

@@ -235,8 +243,8 @@ For more ways of setting environment variables [take a look here](https://docs.c
235243

236244
Screenshots in Cypress do not scale to the viewport size by default. You can change this behavior:
237245

238-
* globally, by changing default screenshot configuration: <code>Cypress.Screenshot.defaults({ capture: 'viewport' });</code>
239-
* locally, by passing screenshot configuration directly to the <code>.matchImage</code> command: <code>cy.matchImage({ screenshotConfig: { capture: 'viewport' } });</code>
246+
- globally, by changing default screenshot configuration: <code>Cypress.Screenshot.defaults({ capture: 'viewport' });</code>
247+
- locally, by passing screenshot configuration directly to the <code>.matchImage</code> command: <code>cy.matchImage({ screenshotConfig: { capture: 'viewport' } });</code>
240248

241249
</details>
242250

Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
describe('Cleanup test', () => {
2-
it('Create screenshot to be removed', () => {
3-
cy.visit('/');
1+
describe("Cleanup test", () => {
2+
it("Create screenshot to be removed", () => {
3+
cy.visit("/");
44
cy.get('[data-testid="description"]').matchImage();
55
});
66
});

example/cypress.config.js

-24
This file was deleted.

example/cypress.config.ts

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { defineConfig } from "cypress";
2+
import { initPlugin } from "@frsource/cypress-plugin-visual-regression-diff/plugins";
3+
4+
module.exports = defineConfig({
5+
video: false,
6+
e2e: {
7+
setupNodeEvents(on, config) {
8+
initPlugin(on, config);
9+
},
10+
specPattern: "cypress/e2e/**/*.cy.{js,jsx,ts,tsx}",
11+
},
12+
13+
component: {
14+
setupNodeEvents(on, config) {
15+
initPlugin(on, config);
16+
},
17+
devServer: {
18+
framework: "vue-cli",
19+
bundler: "webpack",
20+
},
21+
},
22+
});

example/cypress/component/HelloWorld.cy.js

-16
This file was deleted.

0 commit comments

Comments
 (0)