Giter Site home page Giter Site logo

Comments (11)

Keysox avatar Keysox commented on May 21, 2024 12

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.

jackjocross avatar jackjocross commented on May 21, 2024 4

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.

Keysox avatar Keysox commented on May 21, 2024 3

@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.

jackjocross avatar jackjocross commented on May 21, 2024 1

@makeupsomething for sure give it a shot! I'm happy to review any PRs.

from cypress-image-snapshot.

anujpunia avatar anujpunia commented on May 21, 2024 1

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.

edupeeth avatar edupeeth commented on May 21, 2024 1

I shifted to Percy. They have a free version as well and much smoother. Had no luck here.

from cypress-image-snapshot.

jordandlaman avatar jordandlaman commented on May 21, 2024

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.

makeupsomething avatar makeupsomething commented on May 21, 2024

Im pretty new to typescript but would like to have a go at this issue if it is ok?

from cypress-image-snapshot.

lemcii avatar lemcii commented on May 21, 2024
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.

Lukaszli avatar Lukaszli commented on May 21, 2024

Any solution? How to use this plugin with typescript?

from cypress-image-snapshot.

Svish avatar Svish commented on May 21, 2024

@Keysox Think the options are missing Cypress.ScreenshotOptions

from cypress-image-snapshot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.