Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to make jest test the scss? #15

Open
benweizhu opened this issue Nov 20, 2015 · 3 comments
Open

How to make jest test the scss? #15

benweizhu opened this issue Nov 20, 2015 · 3 comments

Comments

@benweizhu
Copy link

I am getting the 'src/components/HelloComponent/Hello.scss: Unexpected token .'

import React from 'react';
import styles from './Hello.scss';

How to make jest test the scss?

@patrikholcak
Copy link

You can join the discussion in #5.

@patrikholcak
Copy link

Cool! But don’t forget that testing classNames will not work.

@benweizhu
Copy link
Author

The solution provided before not working. I ended up with:

var babelJest = require('babel-jest');

module.exports = {
    process: function (src, filename) {
        return babelJest.process(src.replace(/import(.*)from.*\.((less)|(scss)|(svg)).*;/gi, 'let $1 = {};'), filename);
    }
};

This will replace the scss import and assign first regex group with {}

But is there a better solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants