1.0.0 • Published 5 years ago

jest-module-proxy v1.0.0

Weekly downloads
262
License
MIT
Repository
github
Last release
5 years ago

jest-module-proxy · npm Build Status codecov

An identity object for mocking imports inside Jest tests. A drop-in replacement for identity-obj-proxy that works with modern Babel.

Getting Started

yarn add -D jest-module-proxy

Add the following to your Jest config:

"moduleNameMapper": {
  "\\.css$": "jest-module-proxy"
},

And for a React component like this:

import React from 'react';
import styles from './App.module.css';

export default () => (
    <div className={styles.root}>
        <h1 className={styles.hello}>Hello, world!</h1>
    </div>
);
exports[`App renders correctly 1`] = `
<div
  class="root"
>
  <h1
    class="hello"
  >
    Hello, world!
  </h1>
</div>
`;