Giter Site home page Giter Site logo

Vitest support about jest-webextension-mock HOT 5 CLOSED

clarkbw avatar clarkbw commented on May 23, 2024
Vitest support

from jest-webextension-mock.

Comments (5)

clarkbw avatar clarkbw commented on May 23, 2024

Looks like this solution should work vitest-dev/vitest#2667 (comment)

from jest-webextension-mock.

fregante avatar fregante commented on May 23, 2024

I know, I opened that issue there, 😅 but the point of this issue here would be to avoid having figure out any config for it. It looks like it's as easy as using globalThis.jest ?? globalThis.vi here. I don't know if that's desirable here though if you don't use vitest anywhere.

from jest-webextension-mock.

clarkbw avatar clarkbw commented on May 23, 2024

I don't know if that's desirable here though if you don't use vitest anywhere.

I don't use vitest so I'm not inclined to attempt to support it here. I wouldn't mind a shim for it but given we'd need some test infra of both systems to make sure it continues to work I think ultimately this would be a pretty big lift for someone to write and then continue to maintain.

from jest-webextension-mock.

albertpratomo avatar albertpratomo commented on May 23, 2024

@fregante did you manage to mock webextension-polyfill in Vitest tests? If yes could you share how / the public repo that you have? Very much appreciated 🙏🏼

from jest-webextension-mock.

fa-sharp avatar fa-sharp commented on May 23, 2024

For anyone who comes here wondering how to make this library work with Vitest:

// vitest.setup.ts
import { vi } from "vitest";

//@ts-ignore
globalThis.jest = vi;
// vitest.config.ts
export default defineConfig({
  //...
  test: {
    setupFiles: ["vitest.setup.ts", "jest-webextension-mock"],
    sequence: { setupFiles: "list" },
    environment: "jsdom"
  },
  //...
});

I've only been using this for mocking Chrome storage, so I can't speak for the other aspects of web extensions.

from jest-webextension-mock.

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.