How to use the pkg-dir.mockImplementation function in pkg-dir

To help you get started, we’ve selected a few pkg-dir 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 Jordaneisenburger / fallback-studio / src / pwa-studio / packages / pwa-buildpack / lib / WebpackTools / __tests__ / configureWebpack.spec.js View on Github external
jest.mock('fs');
jest.mock('pkg-dir');
jest.mock('webpack-assets-manifest');
jest.mock('../../Utilities/loadEnvironment');
jest.mock('../plugins/RootComponentsPlugin');
jest.mock('../PWADevServer');

const fs = require('fs');
const pkgDir = require('pkg-dir');
const WebpackAssetsManifest = require('webpack-assets-manifest');
const RootComponentsPlugin = require('../plugins/RootComponentsPlugin');
const loadEnvironment = require('../../Utilities/loadEnvironment');
const configureWebpack = require('../configureWebpack');

pkgDir.mockImplementation(x => x);

const mockStat = (dir, file, err = null) => {
    fs.stat.mockImplementationOnce((_, callback) =>
        callback(err, { isDirectory: () => dir, isFile: () => file })
    );
};

const mockEnv = prod =>
    loadEnvironment.mockReturnValueOnce({
        env: process.env,
        sections: jest.fn(),
        section: jest.fn(),
        isProd: prod
    });

const simulate = {

pkg-dir

Find the root directory of a Node.js project or npm package

MIT
Latest version published 7 months ago

Package Health Score

76 / 100
Full package analysis