Git Product home page Git Product logo

Comments (8)

princed avatar princed commented on June 9, 2024

You don't have to include sinon separately, sinon-chai should be exactly enough.

from karma-chai-plugins.

Offirmo avatar Offirmo commented on June 9, 2024

@princed so we have to npm i --save-dev sinon-chai ? Or are you saying karma-chai-plugins should suffice ? (which is not, hence this report)

from karma-chai-plugins.

princed avatar princed commented on June 9, 2024

No, you haven't.
I meant you shouldn't include sinon in frameworks list in config as well: [... 'mocha', 'chai', 'sinon-chai']
Sorry for me being confusing.

from karma-chai-plugins.

Offirmo avatar Offirmo commented on June 9, 2024

Ahh ! I'll try...

from karma-chai-plugins.

Offirmo avatar Offirmo commented on June 9, 2024

Tricky ! I think I got it. In my code, I'm doing const expect = require('chai').expect in order to have a typed expect (for typescript reasons).

However, it appear that doing so returns me another, non sinon-enabled instance of "expect" which is not the same as the global one, which is correctly sinon-enabled. Blame the webpack ?

from karma-chai-plugins.

princed avatar princed commented on June 9, 2024

All that karma plugins stuff doesn't really connect with webpack.
But I have some idea for you: you could use externals option somewhere in your webpack config for tests to be able to β€œrequire” them from global, like:

// webpack-test.config.js
externals: {
    chai: 'var chai'
}

// test.js
import {expect} from 'chai';

from karma-chai-plugins.

Offirmo avatar Offirmo commented on June 9, 2024

Thanks for the help. I ended up not typing sinon :-( Not sure if my coworkers will agree.

Created a PR for warning of what you told me #91

from karma-chai-plugins.

princed avatar princed commented on June 9, 2024

Sinon is rather good. Didn't externals help you?

from karma-chai-plugins.

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.