Skip to content

Commit

Permalink
test: fix edgeCase test case
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Apr 25, 2023
1 parent ef589df commit d851c84
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
28 changes: 20 additions & 8 deletions test/edgeCases.spec.ts
@@ -1,5 +1,5 @@
import * as path from 'path'
import webpack = require('webpack')
import webpack from 'webpack'
import { mfs, bundle, mockBundleAndRun, normalizeNewline } from './utils'

// @ts-ignore
Expand Down Expand Up @@ -30,8 +30,11 @@ function assertComponent({
test('vue rule with include', async () => {
const result = await mockBundleAndRun({
entry: 'basic.vue',
modify: (config) => {
config!.module!.rules[0] = {
modify: (config: any) => {
const i = config.module.rules.findIndex((r) =>
r.test.toString().includes('vue')
)
config.module.rules[i] = {
test: /\.vue$/,
include: /fixtures/,
loader: 'vue-loader',
Expand Down Expand Up @@ -70,8 +73,11 @@ test('test-less oneOf rules', async () => {
test('normalize multiple use + options', async () => {
await bundle({
entry: 'basic.vue',
modify: (config) => {
config!.module!.rules[0] = {
modify: (config: any) => {
const i = config.module.rules.findIndex((r) =>
r.test.toString().includes('vue')
)
config!.module!.rules[i] = {
test: /\.vue$/,
use: [
{
Expand All @@ -88,7 +94,10 @@ test('should not duplicate css modules value imports', async () => {
const { window, exports } = await mockBundleAndRun({
entry: './test/fixtures/duplicate-cssm.js',
modify: (config: any) => {
config!.module!.rules[1] = {
const i = config.module.rules.findIndex((r) =>
r.test.toString().includes('css')
)
config.module.rules[i] = {
test: /\.css$/,
use: [
'style-loader',
Expand Down Expand Up @@ -136,8 +145,11 @@ test('html-webpack-plugin', async () => {
test('usage with null-loader', async () => {
await mockBundleAndRun({
entry: 'basic.vue',
modify: (config) => {
config!.module!.rules[1] = {
modify: (config: any) => {
const i = config.module.rules.findIndex((r) =>
r.test.toString().includes('css')
)
config.module.rules[i] = {
test: /\.css$/,
use: ['null-loader'],
}
Expand Down
8 changes: 4 additions & 4 deletions test/utils.ts
Expand Up @@ -31,6 +31,10 @@ const baseConfig: webpack.Configuration = {
test: /\.vue$/,
loader: 'vue-loader',
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
{
test: /\.ts$/,
loader: process.env.WEBPACK4
Expand All @@ -41,10 +45,6 @@ const baseConfig: webpack.Configuration = {
appendTsSuffixTo: [/\.vue$/],
},
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
],
},
plugins: [
Expand Down

0 comments on commit d851c84

Please sign in to comment.