Created
November 19, 2018 17:39
-
-
Save DSchau/5e828544207ab8173d3aef87a7fa7b33 to your computer and use it in GitHub Desktop.
Unit test for plugin functionality
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| jest.mock('../local-eslint-config-finder', () => jest.fn()) | |
| jest.mock('../eslint-config', () => jest.fn()) | |
| jest.mock('../api-runner-node', () => jest.fn()) | |
| jest.mock('../../redux', () => ({ | |
| store: { | |
| dispatch: jest.fn(), | |
| getState: jest.fn().mockImplementation(() => ({ | |
| program: { | |
| extensions: [] | |
| } | |
| })) | |
| } | |
| })) | |
| const { DefinePlugin } = require(`webpack`) | |
| const webpackConfig = require(`../webpack.config`) | |
| const { store } = require(`../../redux`) | |
| const setup = async ({ | |
| suppliedStage | |
| } = {}) => { | |
| const program = {} | |
| const directory = process.cwd() | |
| await webpackConfig(program, directory, suppliedStage || 'develop') | |
| return store.dispatch.mock.calls[0][0].payload | |
| } | |
| test(`it does not include entire process.env object`, async () => { | |
| const config = await setup() | |
| const definePlugin = config.plugins.find(plugin => plugin instanceof DefinePlugin) | |
| expect(definePlugin.definitions).toEqual(expect.objectContaining({ | |
| 'process.env': '{}' | |
| })) | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment