Skip to content

Fix slow unit test #17465

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ playwright-report/
blob-report/
playwright/.cache/
target/
.debug
.debug/
23 changes: 16 additions & 7 deletions packages/@tailwindcss-postcss/src/index.test.ts
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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`

beforeEach(() =>
writeFile(filepath, `<div class="md:[&:hover]:content-['testing_default_base_path']">`),
)
let filepath: string
let dir: string

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() })
Expand Down