UNPKG

@interaktiv/dia-scripts

Version:

CLI toolbox with common scripts for most sort of projects at DIA

46 lines (40 loc) 1.21 kB
"use strict"; describe('babelrc', () => { let originalEnv, originalExit, originalConsoleWarn; beforeEach(() => { originalEnv = process.env; originalExit = process.exit; process.exit = jest.fn(); originalConsoleWarn = console.warn; console.warn = jest.fn(); }); afterEach(() => { process.env = originalEnv; process.exit = originalExit; console.warn = originalConsoleWarn; jest.resetModules(); }); it('should log warning if treeshake but runtime is not available and is not umd', () => { process.env.BUILD_TREESHAKE = 'true'; process.env.BUILD_FORMAT = 'cjs'; const utils = require('../utils'); Object.assign(utils, { pkg: { dependencies: {} }, appDirectory: '/blah-root' }); require('./babelrc'); expect(console.warn.mock.calls).toMatchSnapshot(); }); it('should throw if it could not detect min supported node version', () => { const utils = require('../utils'); Object.assign(utils, { appDirectory: '/blah-root', getSupportedNodeVersion: () => null }); expect(() => { require('./babelrc'); }).toThrow(/unable to determine the oldest version/i); }); });