Comments (11)
I went ahead and added typings for folks to use: DefinitelyTyped/DefinitelyTyped#41222
Now, all you need to do is yarn add @types/cypress-image-snapshot -D
for this plugin to work with TypeScript!
from cypress-image-snapshot.
Yep that makes sense! So if we add an index.d.ts
to the root of cypress-image-snapshot and publish to NPM again, everyone will receive types without having to touch their node_modules
directly.
I think what would be even better is if we rewrite to use TypeScript and then generate index.d.ts
from our source, similar to how Formik does.
But creating types manually is definitely useful if we want to start there.
from cypress-image-snapshot.
@Svish -- options have been added if you upgrade to 3.1.1
https://github.com/DefinitelyTyped/DefinitelyTyped/pull/41897/files#diff-603108fb86a139bc0934ce518b4267eeR10
from cypress-image-snapshot.
@makeupsomething for sure give it a shot! I'm happy to review any PRs.
from cypress-image-snapshot.
So admittedly I am a TS amateur. I was just playing around with things and I did get it to config a bit easier if I added index.d.ts directly to the node_modules/cypress-image-snapshot/ with
import 'cypress'; declare global { namespace Cypress { interface Chainable { matchImageSnapshot: (options?: any) => void; } } }Obviously hacking a node_modules folder is a no no but I thought that might be a way to go though im not sure how much different it is from having a custom types folder somewhere else. I have seen a few other plugins use this sort of pattern and thought I would give it a shot.
Adding index.d.ts
as you said still gives me error in the .ts spec file-
Property 'matchImageSnapshot' does not exist on type 'Chainable<undefined>'.
from cypress-image-snapshot.
I shifted to Percy. They have a free version as well and much smoother. Had no luck here.
from cypress-image-snapshot.
So admittedly I am a TS amateur. I was just playing around with things and I did get it to config a bit easier if I added index.d.ts directly to the node_modules/cypress-image-snapshot/ with
import 'cypress';
declare global {
namespace Cypress {
interface Chainable {
matchImageSnapshot: (options?: any) => void;
}
}
}
Obviously hacking a node_modules folder is a no no but I thought that might be a way to go though im not sure how much different it is from having a custom types folder somewhere else. I have seen a few other plugins use this sort of pattern and thought I would give it a shot.
from cypress-image-snapshot.
Im pretty new to typescript but would like to have a go at this issue if it is ok?
from cypress-image-snapshot.
import "cypress";
import "jest.d.ts";
import * as JestImageSnapshot from "jest-image-snapshot";
declare global {
namespace Cypress {
interface Chainable {
matchImageSnapshot: (
options?:
| string
| (Partial<
JestImageSnapshot.MatchImageSnapshotOptions &
Loggable &
Timeoutable &
ScreenshotOptions
>),
) => void;
}
}
}
Just based on what I understood from the readme, just a good stop gap for now.
from cypress-image-snapshot.
Any solution? How to use this plugin with typescript?
from cypress-image-snapshot.
@Keysox Think the options are missing Cypress.ScreenshotOptions
from cypress-image-snapshot.
Related Issues (20)
- failureThreshold configuration question HOT 1
- cy.matchImageSnapshot() keeps takeing new screenshots and doesn't validate on any HOT 4
- Upgrade to Cypress version 8
- Upgrade to Cypress version 8 HOT 8
- I am getting the expected failure but the image doesn't have the red spots HOT 1
- matchImageSnapshot command options not being respected in cloud containers
- cy.task('Matching image snapshot') failed with the following error HOT 7
- Please upgrade term-img due to xmldom security issue
- Failure Threshold ENV variable or ENV var for config file HOT 1
- Is the project still in maintaining? HOT 2
- Critical Security vulnerability CVE-2022-22912 in latest version 4.0.1 due to [email protected]
- Update to be compatible with Cypress 10 HOT 31
- Is there any way to host the screenshots on cloud storage
- Unable to click more than one snapshot error. "The snapshot is missing..."
- It is impossible to stop updating UI snapshots after migration to Cypress 10
- How to update Snapshot for specific test instead of all tests HOT 2
- How to use Relative path instead of Absolute path for failed screenshot due to cypress-image-snapshot
- Problems that always pass visual regression tests run with the GitHub action
- Blackout parameter not working when combined with filename
- Store screenshot in the same directory as component is? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cypress-image-snapshot.