Skip to content

Commit

Permalink
cleanup fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
lev875 committed Oct 22, 2023
1 parent c351a64 commit a2366b8
Show file tree
Hide file tree
Showing 14 changed files with 36 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { join } from 'path'

export default {
entryPoints: [join(__dirname, 'file.js'), join(__dirname, 'small.js')],
entryPoints: [join(__dirname, '../file.js'), join(__dirname, '../small.js')],
outdir: join(process.cwd(), 'dist'),
bundle: true,
minify: false
Expand Down
File renamed without changes.
File renamed without changes.
22 changes: 11 additions & 11 deletions packages/esbuild/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ describe('supports custom esbuild config', () => {

it('should work with esm config', async () => {
let config = {
checks: [{ config: fixture('esbuild.config.js') }],
checks: [{ config: fixture('esm/esbuild.config.js') }],
configPath: ROOT_CONFIG
}
await run(config)
Expand All @@ -104,7 +104,7 @@ describe('supports custom entry', () => {

it('should work with esm config', async () => {
let config = {
checks: [{ config: fixture('esbuild.config.js'), entry: ['small'] }],
checks: [{ config: fixture('esm/esbuild.config.js'), entry: ['small'] }],
configPath: ROOT_CONFIG
}
await run(config)
Expand All @@ -130,7 +130,7 @@ describe('throws error on unknown entry', () => {

it('should work with esm config', async () => {
let config = {
checks: [{ config: fixture('esbuild.config.js'), entry: ['unknown'] }],
checks: [{ config: fixture('esm/esbuild.config.js'), entry: ['unknown'] }],
configPath: ROOT_CONFIG
}
let err
Expand Down Expand Up @@ -268,27 +268,27 @@ it('can use `modifyEsbuildConfig` for resolution of aliases', async () => {
it('supports specifying the import', async () => {
expect(
await getSize({
files: [fixture('module.js')],
files: [fixture('esm/module.js')],
import: {
[fixture('module.js')]: '{ A }'
[fixture('esm/module.js')]: '{ A }'
}
})
).toBe(9)

expect(
await getSize({
files: [fixture('module.js')],
files: [fixture('esm/module.js')],
gzip: false,
import: {
[fixture('module.js')]: '{ A }'
[fixture('esm/module.js')]: '{ A }'
}
})
).toBe(1)

expect(
await getSize({
import: {
[fixture('module.js')]: '{ methodA }'
[fixture('esm/module.js')]: '{ methodA }'
}
})
).toBe(86)
Expand All @@ -298,8 +298,8 @@ it('supports import with multiple files', async () => {
expect(
await getSize({
import: {
[fixture('module.js')]: '{ A }',
[fixture('module2.js')]: '{ B }'
[fixture('esm/module.js')]: '{ A }',
[fixture('esm/module2.js')]: '{ B }'
}
})
).toBe(18)
Expand All @@ -309,7 +309,7 @@ it('supports wildcard imports', async () => {
expect(
await getSize({
import: {
[fixture('module.js')]: '*'
[fixture('esm/module.js')]: '*'
}
})
).toBe(191)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions packages/webpack/test/fixtures/esm/file.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
console.log('11111111111')
console.log('11111111111')
console.log('11111111111')
console.log('11111111111')
console.log('11111111111')
1 change: 1 addition & 0 deletions packages/webpack/test/fixtures/esm/small.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log('111111111111111111111')
4 changes: 2 additions & 2 deletions packages/webpack/test/fixtures/esm/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import path from 'path'

export default {
entry: {
file: path.join(__dirname, '../file.js'),
small: path.join(__dirname, '../small.js')
file: path.join(__dirname, 'file.js'),
small: path.join(__dirname, 'small.js')
},
output: {
filename: '[name].js'
Expand Down
32 changes: 16 additions & 16 deletions packages/webpack/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ afterEach(async () => {

it('uses webpack to make bundle', async () => {
let config = {
checks: [{ files: [fixture('big.js')] }]
checks: [{ files: [fixture('cjs/big.js')] }]
}
await run(config)
expect(config).toEqual({
checks: [
{
bundles: [join(config.checks[0].webpackOutput, 'index.js')],
files: [fixture('big.js')],
files: [fixture('cjs/big.js')],
size: 2477,
webpackConfig: config.checks[0].webpackConfig,
webpackOutput: config.checks[0].webpackOutput
Expand All @@ -65,7 +65,7 @@ it('uses webpack to make bundle', async () => {

it('supports ignore', async () => {
let config = {
checks: [{ files: fixture('big.js'), ignore: ['redux'] }]
checks: [{ files: fixture('cjs/big.js'), ignore: ['redux'] }]
}
await run(config)
expect(config.checks[0].size).toBe(160)
Expand All @@ -75,11 +75,11 @@ it('supports ignore', async () => {
describe('supports custom webpack config', () => {
it('should work with commonjs config', async () => {
let config = {
checks: [{ config: fixture('webpack.config.js') }],
checks: [{ config: fixture('cjs/webpack.config.js') }],
configPath: ROOT_CONFIG
}
await run(config)
expect(config.checks[0].size).toBe(1154)
expect(config.checks[0].size).toBe(1160)
})

it('should work with esm config', async () => {
Expand All @@ -88,18 +88,18 @@ describe('supports custom webpack config', () => {
configPath: ROOT_CONFIG
}
await run(config)
expect(config.checks[0].size).toBe(1154)
expect(config.checks[0].size).toBe(1605)
})
})

describe('supports custom entry', () => {
it('should work with commonjs config', async () => {
let config = {
checks: [{ config: fixture('webpack.config.js'), entry: ['small'] }],
checks: [{ config: fixture('cjs/webpack.config.js'), entry: ['small'] }],
configPath: ROOT_CONFIG
}
await run(config)
expect(config.checks[0].size).toBe(566)
expect(config.checks[0].size).toBe(569)
})

it('should work with esm config', async () => {
Expand All @@ -108,14 +108,14 @@ describe('supports custom entry', () => {
configPath: ROOT_CONFIG
}
await run(config)
expect(config.checks[0].size).toBe(566)
expect(config.checks[0].size).toBe(792)
})
})

describe('throws error on unknown entry', () => {
it('should work with commonjs config', async () => {
let config = {
checks: [{ config: fixture('webpack.config.js'), entry: ['unknown'] }],
checks: [{ config: fixture('cjs/webpack.config.js'), entry: ['unknown'] }],
configPath: ROOT_CONFIG
}
let err
Expand Down Expand Up @@ -147,23 +147,23 @@ describe('throws error on unknown entry', () => {

it('allows to disable webpack', async () => {
let config = {
checks: [{ files: [fixture('big.js')], webpack: false }]
checks: [{ files: [fixture('cjs/big.js')], webpack: false }]
}
await run(config)
expect(config.checks[0].size).toBe(55)
})

it('allows to disable gzip', async () => {
let config = {
checks: [{ files: [fixture('small.js')], gzip: false }]
checks: [{ files: [fixture('cjs/small.js')], gzip: false }]
}
await run(config)
expect(config.checks[0].size).toBe(37)
})

it('throws on missed file plugin', async () => {
let config = {
checks: [{ files: [fixture('small.js')] }]
checks: [{ files: [fixture('cjs/small.js')] }]
}
try {
await webpack.step20(config, config.checks[0])
Expand All @@ -183,7 +183,7 @@ it('throws on missed file plugin', async () => {
it('supports --clean-dir', async () => {
let dist = join(DIST, 'index.js')
let config = {
checks: [{ files: [fixture('small.js')] }],
checks: [{ files: [fixture('cjs/small.js')] }],
cleanDir: true,
saveBundle: DIST
}
Expand All @@ -197,7 +197,7 @@ it('supports --clean-dir', async () => {
it('throws error on not empty bundle dir', async () => {
let dist = join(DIST, 'index.js')
let config = {
checks: [{ files: [fixture('small.js')] }],
checks: [{ files: [fixture('cjs/small.js')] }],
saveBundle: DIST
}
await run(config)
Expand All @@ -216,7 +216,7 @@ it('throws error on not empty bundle dir', async () => {
it('throws unsupported error --save-bundle', async () => {
let distFile = join(DIST, 'index.js')
let config = {
checks: [{ files: [fixture('small.js')] }],
checks: [{ files: [fixture('cjs/small.js')] }],
saveBundle: distFile
}
await mkdir(DIST)
Expand Down

0 comments on commit a2366b8

Please sign in to comment.