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:
Robin Malfait 2021-08-27 15:47:39 +02:00 committed by GitHub
parent 211f40b175
commit 96ef15039b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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))
})
})
)