mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
Fix slow unit test (#17465)
This PR reworks a unit test that created a file in the project root and
then proceeded by scanning everything in the git root for candidates.
The issue specifically is that with the `.debug/` folder, our project
root can grow quite a bit which makes this test slower the more you work
on other tests...
To fix this we now simply create a tmp folder with only that one test
file. 🚀
This commit is contained in:
parent
eec1bf2b84
commit
c7ba564f92
2
.gitignore
vendored
2
.gitignore
vendored
@ -7,4 +7,4 @@ playwright-report/
|
||||
blob-report/
|
||||
playwright/.cache/
|
||||
target/
|
||||
.debug
|
||||
.debug/
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
import dedent from 'dedent'
|
||||
import { unlink, writeFile } from 'node:fs/promises'
|
||||
import { mkdir, mkdtemp, unlink, writeFile } from 'node:fs/promises'
|
||||
import { tmpdir } from 'node:os'
|
||||
import path from 'path'
|
||||
import postcss from 'postcss'
|
||||
import { afterEach, beforeEach, describe, expect, test } from 'vitest'
|
||||
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest'
|
||||
import tailwindcss from './index'
|
||||
|
||||
// We give this file path to PostCSS for processing.
|
||||
@ -106,14 +108,21 @@ test('@apply can be used without emitting the theme in the CSS file', async () =
|
||||
})
|
||||
|
||||
describe('processing without specifying a base path', () => {
|
||||
let filepath = `${process.cwd()}/my-test-file.html`
|
||||
let filepath: string
|
||||
let dir: string
|
||||
|
||||
beforeEach(() =>
|
||||
writeFile(filepath, `<div class="md:[&:hover]:content-['testing_default_base_path']">`),
|
||||
)
|
||||
beforeEach(async () => {
|
||||
dir = await mkdtemp(path.join(tmpdir(), 'tw-postcss'))
|
||||
await mkdir(dir, { recursive: true })
|
||||
filepath = path.join(dir, 'my-test-file.html')
|
||||
await writeFile(filepath, `<div class="md:[&:hover]:content-['testing_default_base_path']">`)
|
||||
})
|
||||
afterEach(() => unlink(filepath))
|
||||
|
||||
test('the current working directory is used by default', async () => {
|
||||
const spy = vi.spyOn(process, 'cwd')
|
||||
spy.mockReturnValue(dir)
|
||||
|
||||
let processor = postcss([tailwindcss({ optimize: { minify: false } })])
|
||||
|
||||
let result = await processor.process(`@import "tailwindcss"`, { from: inputCssFilePath() })
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user