mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
* Run test suite against both engines * make eslint happy * only run `stable` tests on Node 12 * use normal expectation instead of snapshot file When we run the tests only against `stable` (for node 12), then the snapshots exists for the `Oxide` build. They are marked as `obsolete` and will cause the `npm run test` script to fail. Sadly. Inlined them for now, but ideally we make those tests more blackbox-y so that we test that we get source maps and that we can map the sourcemap back to the input files (without looking at the actual annotations). * properly indent inline css Co-authored-by: Adam Wathan <4323180+adamwathan@users.noreply.github.com> Co-authored-by: Robin Malfait <malfait.robin@gmail.com>
81 lines
1.8 KiB
JavaScript
81 lines
1.8 KiB
JavaScript
import path from 'path'
|
|
import postcss from 'postcss'
|
|
import tailwind from '../../src'
|
|
import { env } from '../../src/lib/sharedState'
|
|
|
|
export * from './strings'
|
|
export * from './defaults'
|
|
|
|
export let map = JSON.stringify({
|
|
version: 3,
|
|
file: null,
|
|
sources: [],
|
|
names: [],
|
|
mappings: '',
|
|
})
|
|
|
|
export function run(input, config, plugin = tailwind) {
|
|
let { currentTestName } = expect.getState()
|
|
|
|
return postcss(plugin(config)).process(input, {
|
|
from: `${path.resolve(__filename)}?test=${currentTestName}`,
|
|
})
|
|
}
|
|
|
|
export function runWithSourceMaps(input, config, plugin = tailwind) {
|
|
let { currentTestName } = expect.getState()
|
|
|
|
return postcss(plugin(config)).process(input, {
|
|
from: `${path.resolve(__filename)}?test=${currentTestName}`,
|
|
map: {
|
|
prev: map,
|
|
},
|
|
})
|
|
}
|
|
|
|
let nullTest = Object.assign(function () {}, {
|
|
skip: () => {},
|
|
only: () => {},
|
|
each: () => () => {},
|
|
todo: () => {},
|
|
})
|
|
let nullProxy = new Proxy(
|
|
{
|
|
test: nullTest,
|
|
it: nullTest,
|
|
xit: nullTest.skip,
|
|
fit: nullTest.only,
|
|
xdescribe: nullTest.skip,
|
|
fdescribe: nullTest.only,
|
|
},
|
|
{
|
|
get(target, prop, _receiver) {
|
|
if (prop in target) {
|
|
return target[prop]
|
|
}
|
|
return Object.assign(() => {
|
|
return nullProxy
|
|
}, nullProxy)
|
|
},
|
|
}
|
|
)
|
|
|
|
export function crosscheck(fn) {
|
|
let engines =
|
|
env.ENGINE === 'oxide' ? [{ engine: 'Stable' }, { engine: 'Oxide' }] : [{ engine: 'Stable' }]
|
|
|
|
describe.each(engines)('$engine', ({ engine }) => {
|
|
let engines = {
|
|
oxide: engine === 'Oxide' ? globalThis : nullProxy,
|
|
stable: engine === 'Stable' ? globalThis : nullProxy,
|
|
engine: { oxide: engine === 'Oxide', stable: engine === 'Stable' },
|
|
}
|
|
|
|
beforeEach(() => {
|
|
env.OXIDE = engines.engine.oxide
|
|
})
|
|
|
|
fn(engines)
|
|
})
|
|
}
|