Skip to content

Commit 12eb5ae

Browse files
authored
Cleanup noisy test output (#20015)
This PR cleans up the noisy test output where some `console.warn` messages were leaking into the test output. This also uses the `src/` files instead of the `dist/` files of `@tailwindcss/node` to get rid of a source map related warning in tests. It also means that we don't have to rebuild `@tailwindcss/node` when we make changes. ## Test plan 1. Existing tests pass 2. Output is clean when running tests (`vitest run --reporter=minimal`) Before: <img width="1193" height="1376" alt="image" src="https://github.com/user-attachments/assets/9aceab62-cd99-4391-9734-0ae5c4c3fb48" /> After: <img width="1099" height="294" alt="image" src="https://github.com/user-attachments/assets/3ada4a0a-8a7a-48a7-9fbd-f3d5dd8700a5" />
1 parent 4255671 commit 12eb5ae

4 files changed

Lines changed: 48 additions & 8 deletions

File tree

packages/@tailwindcss-node/package.json

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,37 @@
1919
],
2020
"publishConfig": {
2121
"provenance": true,
22-
"access": "public"
22+
"access": "public",
23+
"exports": {
24+
".": {
25+
"types": "./dist/index.d.ts",
26+
"import": "./dist/index.mjs",
27+
"require": "./dist/index.js"
28+
},
29+
"./require-cache": {
30+
"types": "./dist/require-cache.d.ts",
31+
"default": "./dist/require-cache.js"
32+
},
33+
"./esm-cache-loader": {
34+
"types": "./dist/esm-cache.loader.d.mts",
35+
"default": "./dist/esm-cache.loader.mjs"
36+
}
37+
}
2338
},
2439
"exports": {
2540
".": {
26-
"types": "./dist/index.d.ts",
27-
"import": "./dist/index.mjs",
28-
"require": "./dist/index.js"
41+
"types": "./src/index.ts",
42+
"import": "./src/index.ts",
43+
"require": "./src/index.cts"
2944
},
3045
"./require-cache": {
31-
"types": "./dist/require-cache.d.ts",
32-
"default": "./dist/require-cache.js"
46+
"types": "./src/require-cache.ts",
47+
"import": "./src/require-cache.ts",
48+
"require": "./src/require-cache.cts"
3349
},
3450
"./esm-cache-loader": {
35-
"types": "./dist/esm-cache.loader.d.mts",
36-
"default": "./dist/esm-cache.loader.mjs"
51+
"types": "./src/esm-cache.loader.mts",
52+
"default": "./src/esm-cache.loader.mts"
3753
}
3854
},
3955
"dependencies": {
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export function clearRequireCache(files: string[]) {
2+
for (let key of files) {
3+
delete require.cache[key]
4+
}
5+
}

packages/@tailwindcss-postcss/src/index.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ describe('processing without specifying a base path', () => {
146146
})
147147

148148
test('fallback to `base` directory when `result.opts.from` is not provided', async () => {
149+
using _ = vi.spyOn(console, 'warn').mockImplementation(() => {})
150+
149151
let processor = postcss([
150152
tailwindcss({ base: `${__dirname}/fixtures/example-project`, optimize: { minify: false } }),
151153
])

packages/tailwindcss/src/utilities.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30148,6 +30148,7 @@ describe('custom utilities', () => {
3014830148
})
3014930149

3015030150
test('resolving unsupported bare values', async () => {
30151+
using spy = vi.spyOn(console, 'warn').mockImplementation(() => {})
3015130152
let input = css`
3015230153
@utility tab-* {
3015330154
tab-size: --value(color);
@@ -30157,6 +30158,22 @@ describe('custom utilities', () => {
3015730158
`
3015830159

3015930160
expect(await compileCss(input, ['tab-#0088cc', 'tab-foo'])).toEqual('')
30161+
expect(
30162+
`\n${spy.mock.calls
30163+
.map((c) => c.join(' '))
30164+
.join('\n')
30165+
.trim()}\n`,
30166+
).toMatchInlineSnapshot(`
30167+
"
30168+
Unsupported bare value data type: "color".
30169+
Only valid data types are: "number", "integer", "ratio", "percentage".
30170+
30171+
\`\`\`css
30172+
--value(color)
30173+
^^^^^
30174+
\`\`\`
30175+
"
30176+
`)
3016030177
})
3016130178

3016230179
test('resolving arbitrary values', async () => {

0 commit comments

Comments
 (0)