@berun/runner-mdx
Version:
BeRun runner for building MDX documentation applications
143 lines (119 loc) • 3.81 kB
text/typescript
import presetReact from '@berun/preset-react'
import { create as berunJs } from '@berun/berun'
import presetMdx from '../src'
test('Gets webpack core configuration', () => {
const berun = berunJs(presetReact)
berun.use(presetMdx)
expect(berun.webpack.get('mode')).toEqual('development')
expect(berun.webpack.get('devtool')).toEqual('cheap-module-source-map')
expect(berun.webpack.node.entries()).toEqual({
dgram: 'empty',
fs: 'empty',
net: 'empty',
tls: 'empty',
childProcess: 'empty'
})
expect(berun.webpack.output.entries()).toMatchObject({
pathinfo: true,
filename: 'static/js/[name].js',
chunkFilename: 'static/js/[name].chunk.js',
publicPath: '/',
devtoolModuleFilenameTemplate: expect.any(Function)
})
expect(berun.webpack.performance.entries()).toEqual({
hints: false
})
expect(berun.webpack.entry('main').values()).toEqual([
'/Volumes/DATA/projects/berun/packages/runner-web-polyfills/src/polyfills.ts',
'/Volumes/DATA/projects/berun/node_modules/react-dev-utils/webpackHotDevClient.js',
'/Volumes/DATA/projects/berun/packages/runner-mdx/src/index.ts'
])
expect(berun.webpack.module.get('strictExportPresence')).toEqual(true)
expect(berun.webpack.module.rule('parser').entries()).toEqual({
parser: {
requireEnsure: false
}
})
})
test('Gets Webpack resolve configuration', () => {
const berun = berunJs(presetReact)
berun.use(presetMdx)
expect(berun.webpack.resolve.toConfig()).toMatchObject({
alias: {
'@babel/runtime':
'/Volumes/DATA/projects/berun/node_modules/@babel/runtime',
'react-native': 'react-native-web'
},
extensions: [
'.ts',
'.tsx',
'.web.js',
'.mjs',
'.js',
'.json',
'.web.jsx',
'.jsx'
],
modules: ['node_modules'],
plugins: expect.arrayContaining([expect.any(Object)])
})
})
test('Gets Webpack production core configuration', () => {
process.env.NODE_ENV = 'production'
const berun = berunJs(presetReact)
berun.use(presetMdx)
expect(berun.webpack.get('mode')).toEqual('production')
expect(berun.webpack.get('devtool')).toEqual(false)
expect(berun.webpack.get('bail')).toEqual(true)
expect(berun.webpack.node.entries()).toEqual({
dgram: 'empty',
fs: 'empty',
net: 'empty',
tls: 'empty',
childProcess: 'empty'
})
expect(berun.webpack.output.entries()).toMatchObject({
path: '/Volumes/DATA/projects/berun/packages/runner-mdx/build',
filename: 'static/js/[name].[chunkhash:8].js',
chunkFilename: 'static/js/[name].[chunkhash:8].chunk.js',
publicPath: '/',
devtoolModuleFilenameTemplate: expect.any(Function)
})
expect(berun.webpack.performance.entries()).toEqual({
hints: false
})
expect(berun.webpack.entry('main').values()).toEqual([
'/Volumes/DATA/projects/berun/packages/runner-web-polyfills/src/polyfills.ts',
'/Volumes/DATA/projects/berun/packages/runner-mdx/src/index.ts'
])
expect(berun.webpack.module.get('strictExportPresence')).toEqual(true)
expect(berun.webpack.module.rule('parser').entries()).toEqual({
parser: {
requireEnsure: false
}
})
})
test('Gets Webpack production resolve configuration', () => {
process.env.NODE_ENV = 'production'
const berun = berunJs(presetReact)
berun.use(presetMdx)
expect(berun.webpack.resolve.toConfig()).toMatchObject({
alias: {
'@babel/runtime':
'/Volumes/DATA/projects/berun/node_modules/@babel/runtime',
'react-native': 'react-native-web'
},
extensions: [
'.ts',
'.tsx',
'.web.js',
'.mjs',
'.js',
'.json',
'.web.jsx',
'.jsx'
],
modules: ['node_modules'],
plugins: expect.arrayContaining([expect.any(Object)])
})
})