GithubHelp home page GithubHelp logo

Support for CSS modules about vue-jest HOT 5 CLOSED

LinusBorg avatar LinusBorg commented on May 19, 2024 3
Support for CSS modules

from vue-jest.

Comments (5)

eddyerburgh avatar eddyerburgh commented on May 19, 2024

Option B would be the best approach, I won't have time to implement it for a few weeks. Would you be able to make a PR?

If not, we could do option A as a quick fix.

from vue-jest.

LinusBorg avatar LinusBorg commented on May 19, 2024

I am off work for the coming week, would try a PR.

from vue-jest.

danielbastos11 avatar danielbastos11 commented on May 19, 2024

Any updates? I'd love to help if needed.

from vue-jest.

danielbastos11 avatar danielbastos11 commented on May 19, 2024

I just made a PR using option B.
I made three decisons:

  1. I decided to use extract-from-css instead of string-extract-class-names because the latter would claim .5px is a CSS class in letter-spacing: 0.5px. The former seems to work just fine.

  2. In order to inject the mock object into the component, I am using a code like the following at the end of the output (take a look the PR for the actual version):

;(function() {
  var render = _Component.render
  _Component.render = function(h) {
    this['$style'] = {/* mock object */}
    return render.call(this, h)
  }
})()

I don't know if there's a better way to do this. Let me know if there is.

  1. I added Stylus as a peer dependency, since other users might use SASS, for instance. This is causing the tests to fail, though. (they pass just fine once stylus is installed)

from vue-jest.

lzgrzebski avatar lzgrzebski commented on May 19, 2024

Im populating my colors from scss variables and Im using in through this. $style, but for some reason this is not working when running unit tests in jest, through yarn serve all works fine. Any ideas? Am I doing smth wrong?
`<style lang="scss" module>
@import '@/styles/variables.scss';
:export {
primary: $color-primary;
secondary: $color-secondary;

success: $color-success;
danger: $color-danger;
info: $color-danger;

light: $color-light;
white: $color-white;

}
</style>`

Why am I doing this? Im using in couple of places colors in js and want to have it in one place.
Inspiration comes from here css-modules/css-modules#86 (comment)

Currently Im just getting empty obj in jest and the object is populated normally when Im running the app.

Is this valid use case @eddyerburgh ?

from vue-jest.

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.