question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

css-modules have inconsistent className hash using babel-plugin-webpack-loaders

See original GitHub issue

Description

As title, test failed with AVA but passed with mocha.

Test Source

import test from 'ava';
import React from 'react';
import { shallow } from 'enzyme';

import Button from './Button';
import styles from './Button.css';

test('has hashed .btn className', t => {
  const element = shallow(<Button>Submit</Button>);
  const button = element.find('button');
  t.is(button.prop('className'), styles.btn);
})

Source Code

Error Message & Stack Trace

✖ has hashed .btn className   
  t.is(button.prop('className'), styles.btn)
              |                         |   
              "Button__btn___3T3BQ"     "Button__btn___2ZBj1"

2016-09-08 11 53 19

Config

{
  "ava": {
    "files": [
      "src/Button.ava.spec.js"
    ],
    "source": [
      "src/Button.js"
    ],
    "concurrency": 5,
    "failFast": true,
    "tap": false,
    "verbose": true,
    "require": [
      "babel-register"
    ],
    "babel": "inherit"
  }
}

Command-Line Arguments

NODE_ENV=test CONFIG=$(pwd)/webpack.config.test.js BABEL_DISABLE_CACHE=1 ava

Relevant Links

Environment

Node.js v6.2.0
darwin 15.2.0
ava 0.16.0
npm 3.8.9

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
nfcamposcommented, Sep 24, 2016

for css modules i use css-modules-require-hook (e.g. ava -r css-modules-require-hook/preset) and it works ok

0reactions
novemberborncommented, Aug 28, 2017

Closing due to inactivity.

Read more comments on GitHub >

github_iconTop Results From Across the Web

babel-plugin-react-css-modules does not change class name ...
Rant: One of the many reasons I'm against the create-react-app (CRA) is because of how inflexible it can be when it comes to...
Read more >
Class name does not match style name with babel-plugin ...
I'm trying to add babel-plugin-react-css-modules to my webpack project and the style names ... in the style class names, and then the differing...
Read more >
css-loader | Yarn - Package Manager
Class names will be exported as is. 'camelCase', string, Class names will be camelized, the original class name will not to be removed...
Read more >
Content Types - ESBuild
Some file extensions already have a loader configured for them by default, ... However, if you're using esbuild to transform ES5 code, you...
Read more >
gradle default configuration
To begin, you'll need to install css-loader: Then add the plugin to your webpack config. Using false value increase performance because we avoid...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found