How to use the glob.__setMockFiles function in glob

To help you get started, we’ve selected a few glob examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github 104corp / espack / lib / api / __tests__ / index.spec.js View on Github external
import HtmlWebpackPlugin from 'html-webpack-plugin';
import espack from '../index';
import webpackConfig from '../../webpack.config';
import CSSExtractPlugin from '../plugins/CSSExtractPlugin';
import EventCallbackPlugin from '../plugins/EventCallbackPlugin';
import { setConfigOptions, OUTPUT_FILE_NAME, INFO_CHUNK_NAME } from '../../config';
import presetStage from '../../babel/preset-stage';

jest.unmock('../../config');
jest.mock('fs-extra');
jest.mock('glob');
jest.unmock('webpack');
jest.mock('mini-css-extract-plugin');
jest.mock('uglifyjs-webpack-plugin');

require('glob').__setMockFiles([ // eslint-disable-line no-underscore-dangle, global-require
  'src/pages/index.js',
]);

global.console.log = jest.fn();
const Api = espack.constructor;
jest.spyOn(Api, 'log');


describe('API 需要先提供 config 驗證', () => {
  beforeEach(() => {
    setConfigOptions({
      dev: false,
      dropConsole: false,
      port: '8888',
      viewsFolder: '.',
      staticFolder: '.',
github 104corp / espack / lib / __tests__ / webpack.base.config.spec.js View on Github external
beforeEach(() => {
    require('glob').__setMockFiles([ // eslint-disable-line no-underscore-dangle, global-require
      'src/pages/index.js',
    ]);
  });