How to use the jest-resolve/build/defaultResolver.default function in jest-resolve

To help you get started, we’ve selected a few jest-resolve 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 salesforce / lwc-test / packages / @lwc / jest-resolver / src / index.js View on Github external
const { resolve, extname, join, dirname, basename } = require('path');
const lwcResolver = require('@lwc/module-resolver');

/*
 * In Jest version 24 the default resolver was renamed to camelCase. Temporarily
 * support both file names until consumers upgrade their Jest version.
 *
 * Jest master branch has the default resolver passed as a param to custom
 * resolvers like this. Once that is released we can remove this entire block.
 * https://github.com/facebook/jest/commit/3f4661f141562aeca65cdad3802e930835dcf0d9
 */
let resolver;
try {
    resolver = require('jest-resolve/build/default_resolver').default;
} catch (e) {
    resolver = require('jest-resolve/build/defaultResolver').default;
}

const EMPTY_CSS_MOCK = resolve(__dirname, '..', 'resources', 'emptyStyleMock.js');
const EMPTY_HTML_MOCK = resolve(__dirname, '..', 'resources', 'emptyHtmlMock.js');

const WHITELISTED_LWC_PACKAGES = {
    lwc: '@lwc/engine',
    'wire-service': '@lwc/wire-service',
    'wire-service-jest-util': 'lwc-wire-service-jest-util',
};
const lwcMap = lwcResolver.resolveModules();

// This logic is somewhat the same in the compiler resolution system
// We should try to consolidate it at some point.
function isImplicitHTMLImport(importee, { basedir }) {
    const ext = extname(importee);
github salesforce / lwc / packages / @lwc / jest-resolver / src / index.js View on Github external
const { resolve, extname, join, dirname, basename } = require('path');
const lwcNpmResolver = require('@lwc/module-resolver');

/*
 * In Jest version 24 the default resolver was renamed to camelCase. Temporarily
 * support both file names until consumers upgrade their Jest version.
 *
 * Jest master branch has the default resolver passed as a param to custom
 * resolvers like this. Once that is released we can remove this entire block.
 * https://github.com/facebook/jest/commit/3f4661f141562aeca65cdad3802e930835dcf0d9
 */
let resolver;
try {
    resolver = require('jest-resolve/build/default_resolver').default;
} catch (e) {
    resolver = require('jest-resolve/build/defaultResolver').default;
}

const EMPTY_CSS_MOCK = resolve(__dirname, '..', 'resources', 'emptyStyleMock.js');
const EMPTY_HTML_MOCK = resolve(__dirname, '..', 'resources', 'emptyHtmlMock.js');

const WHITELISTED_LWC_PACKAGES = {
    lwc: '@lwc/engine',
    'wire-service': '@lwc/wire-service',
    'wire-service-jest-util': 'lwc-wire-service-jest-util',
};
const lwcMap = lwcNpmResolver.resolveLwcNpmModules();

// This logic is somewhat the same in the compiler resolution system
// We should try to consolidate it at some point.
function isImplicitHTMLImport(importee, { basedir }) {
    const ext = extname(importee);

jest-resolve

MIT
Latest version published 1 year ago

Package Health Score

88 / 100
Full package analysis

Similar packages