mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
Ensure purge tests work even for version mismatches (#5316)
We applied the same treatment for the sanity tests, where we ignore the first line (the tailwind header). An odd issue I have found is that diffing of big css files is _very_ slow. When te tests pass, then the first test takes `3302 ms`, however, when it fails it takes `477482 ms` on my machine. That's almost 8 minutes.
This commit is contained in:
parent
211f40b175
commit
96ef15039b
@ -20,6 +20,16 @@ function suppressConsoleLogs(cb, type = 'warn') {
|
||||
}
|
||||
}
|
||||
|
||||
function dropTailwindHeader(css) {
|
||||
let [header, ...lines] = css.split('\n')
|
||||
|
||||
expect(
|
||||
/\/*! tailwindcss v\d*\.\d*\.\d* \| MIT License \| https:\/\/tailwindcss.com \*\//g.test(header)
|
||||
).toBe(true)
|
||||
|
||||
return lines.join('\n')
|
||||
}
|
||||
|
||||
function extractRules(root) {
|
||||
let rules = []
|
||||
|
||||
@ -450,7 +460,7 @@ test(
|
||||
'utf8'
|
||||
)
|
||||
|
||||
expect(result.css).toMatchCss(expected)
|
||||
expect(dropTailwindHeader(result.css)).toMatchCss(dropTailwindHeader(expected))
|
||||
})
|
||||
})
|
||||
)
|
||||
@ -477,7 +487,7 @@ test('does not purge if the array is empty', () => {
|
||||
'utf8'
|
||||
)
|
||||
|
||||
expect(result.css).toMatchCss(expected)
|
||||
expect(dropTailwindHeader(result.css)).toMatchCss(dropTailwindHeader(expected))
|
||||
})
|
||||
})
|
||||
)
|
||||
@ -502,7 +512,7 @@ test('does not purge if explicitly disabled', () => {
|
||||
'utf8'
|
||||
)
|
||||
|
||||
expect(result.css).toMatchCss(expected)
|
||||
expect(dropTailwindHeader(result.css)).toMatchCss(dropTailwindHeader(expected))
|
||||
})
|
||||
})
|
||||
)
|
||||
@ -527,7 +537,7 @@ test('does not purge if purge is simply false', () => {
|
||||
'utf8'
|
||||
)
|
||||
|
||||
expect(result.css).toMatchCss(expected)
|
||||
expect(dropTailwindHeader(result.css)).toMatchCss(dropTailwindHeader(expected))
|
||||
})
|
||||
})
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user