Skip to content

Commit be89744

Browse files
committed
append test name to postcss from option in purge tests
fixes tests hanging
1 parent 60b51d6 commit be89744

File tree

1 file changed

+22
-18
lines changed

1 file changed

+22
-18
lines changed

tests/purgeUnusedStyles.test.js

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ async function inProduction(callback) {
3939
return result
4040
}
4141

42+
function withTestName(path) {
43+
return `${path}?test=${expect.getState().currentTestName}`
44+
}
45+
4246
const config = {
4347
...defaultConfig,
4448
...customConfig,
@@ -93,22 +97,22 @@ test('purges unused classes', () => {
9397
purge: [path.resolve(`${__dirname}/fixtures/**/*.html`)],
9498
}),
9599
])
96-
.process(input, { from: inputPath })
100+
.process(input, { from: withTestName(inputPath) })
97101
.then((result) => {
98102
assertPurged(result)
99103
})
100104
})
101105
)
102106
})
103107

104-
test.skip('purge patterns are resolved relative to the config file', () => {
108+
test('purge patterns are resolved relative to the config file', () => {
105109
return inProduction(
106110
suppressConsoleLogs(() => {
107111
const inputPath = path.resolve(`${__dirname}/fixtures/tailwind-input.css`)
108112
const input = fs.readFileSync(inputPath, 'utf8')
109113

110114
return postcss([tailwind(path.resolve(`${__dirname}/fixtures/custom-purge-config.js`))])
111-
.process(input, { from: inputPath })
115+
.process(input, { from: withTestName(inputPath) })
112116
.then((result) => {
113117
assertPurged(result)
114118
})
@@ -275,7 +279,7 @@ test('purges unused classes with important string', () => {
275279
purge: [path.resolve(`${__dirname}/fixtures/**/*.html`)],
276280
}),
277281
])
278-
.process(input, { from: inputPath })
282+
.process(input, { from: withTestName(inputPath) })
279283
.then((result) => {
280284
assertPurged(result)
281285
})
@@ -298,7 +302,7 @@ test('mode must be a valid value', () => {
298302
content: [path.resolve(`${__dirname}/fixtures/**/*.html`)],
299303
},
300304
}),
301-
]).process(input, { from: inputPath })
305+
]).process(input, { from: withTestName(inputPath) })
302306
).rejects.toThrow()
303307
})
304308
)
@@ -319,7 +323,7 @@ test('components are purged by default in layers mode', () => {
319323
purge: [path.resolve(`${__dirname}/fixtures/**/*.html`)],
320324
}),
321325
])
322-
.process(input, { from: inputPath })
326+
.process(input, { from: withTestName(inputPath) })
323327
.then((result) => {
324328
expect(result.css).not.toContain('.container')
325329
assertPurged(result)
@@ -347,7 +351,7 @@ test('you can specify which layers to purge', () => {
347351
},
348352
}),
349353
])
350-
.process(input, { from: inputPath })
354+
.process(input, { from: withTestName(inputPath) })
351355
.then((result) => {
352356
const rules = extractRules(result.root)
353357
expect(rules).toContain('optgroup')
@@ -377,7 +381,7 @@ test('you can purge just base and component layers (but why)', () => {
377381
},
378382
}),
379383
])
380-
.process(input, { from: inputPath })
384+
.process(input, { from: withTestName(inputPath) })
381385
.then((result) => {
382386
const rules = extractRules(result.root)
383387
expect(rules).not.toContain('[type="checkbox"]')
@@ -439,7 +443,7 @@ test(
439443
purge: [path.resolve(`${__dirname}/fixtures/**/*.html`)],
440444
}),
441445
])
442-
.process(input, { from: inputPath })
446+
.process(input, { from: withTestName(inputPath) })
443447
.then((result) => {
444448
const expected = fs.readFileSync(
445449
path.resolve(`${__dirname}/fixtures/tailwind-output.css`),
@@ -465,7 +469,7 @@ test('does not purge if the array is empty', () => {
465469
purge: [],
466470
}),
467471
])
468-
.process(input, { from: inputPath })
472+
.process(input, { from: withTestName(inputPath) })
469473
.then((result) => {
470474
process.env.NODE_ENV = OLD_NODE_ENV
471475
const expected = fs.readFileSync(
@@ -491,7 +495,7 @@ test('does not purge if explicitly disabled', () => {
491495
purge: { enabled: false },
492496
}),
493497
])
494-
.process(input, { from: inputPath })
498+
.process(input, { from: withTestName(inputPath) })
495499
.then((result) => {
496500
const expected = fs.readFileSync(
497501
path.resolve(`${__dirname}/fixtures/tailwind-output.css`),
@@ -516,7 +520,7 @@ test('does not purge if purge is simply false', () => {
516520
purge: false,
517521
}),
518522
])
519-
.process(input, { from: inputPath })
523+
.process(input, { from: withTestName(inputPath) })
520524
.then((result) => {
521525
const expected = fs.readFileSync(
522526
path.resolve(`${__dirname}/fixtures/tailwind-output.css`),
@@ -541,7 +545,7 @@ test('purges outside of production if explicitly enabled', () => {
541545
purge: { enabled: true, content: [path.resolve(`${__dirname}/fixtures/**/*.html`)] },
542546
}),
543547
])
544-
.process(input, { from: inputPath })
548+
.process(input, { from: withTestName(inputPath) })
545549
.then((result) => {
546550
assertPurged(result)
547551
})
@@ -567,7 +571,7 @@ test(
567571
},
568572
}),
569573
])
570-
.process(input, { from: inputPath })
574+
.process(input, { from: withTestName(inputPath) })
571575
.then((result) => {
572576
expect(result.css).toContain('.md\\:bg-green-500')
573577
assertPurged(result)
@@ -596,7 +600,7 @@ test(
596600
css.walkComments((c) => c.remove())
597601
},
598602
])
599-
.process(input, { from: inputPath })
603+
.process(input, { from: withTestName(inputPath) })
600604
.then((result) => {
601605
expect(result.css).toContain('html')
602606
expect(result.css).toContain('body')
@@ -624,7 +628,7 @@ test('element selectors are preserved by default', () => {
624628
},
625629
}),
626630
])
627-
.process(input, { from: inputPath })
631+
.process(input, { from: withTestName(inputPath) })
628632
.then((result) => {
629633
const rules = extractRules(result.root)
630634
;[
@@ -678,7 +682,7 @@ test('element selectors are preserved even when defaultExtractor is overridden',
678682
},
679683
}),
680684
])
681-
.process(input, { from: inputPath })
685+
.process(input, { from: withTestName(inputPath) })
682686
.then((result) => {
683687
const rules = extractRules(result.root)
684688
;[
@@ -729,7 +733,7 @@ test('preserving element selectors can be disabled', () => {
729733
},
730734
}),
731735
])
732-
.process(input, { from: inputPath })
736+
.process(input, { from: withTestName(inputPath) })
733737
.then((result) => {
734738
const rules = extractRules(result.root)
735739

0 commit comments

Comments
 (0)