rollup-plugin-mockr
Allows mocking ES6 modules for tests. Heavily inspired by rollup-plugin-alias.
Installation
npm install rollup-plugin-mockr [--save-dev]
Usage
import { rollup } from 'rollup';
import mockr from 'rollup-plugin-mockr';
rollup( {
entry: './src/index.js',
plugins: [
mockr( {
'./src/index.js': {
exampleLib: 'path/to/localMock'
}
} )
]
} );
You can also specify file extension for ES6 modules:
rollup( {
entry: './src/index.js',
plugins: [
mockr( {
modules: {
'./src/index.js': {
exampleLib: 'path/to/localMock'
}
},
fileExtension: 'jsm'
} )
]
} );
You can also specify more than one entry point (added with karma-rollup-preprocessor in mind; unfortunately it doesn't work with rollup-plugin-multi-entry… yet).
rollup( {
entry: './src/index.js',
plugins: [
mockr( {
'./src/index.js': {
exampleLib: 'path/to/localMock'
},
'./src/index2.js': {
someOtherLib: 'path/to/localMock2'
}
} )
]
} );
License
See LICENSE file for details.