Skip to content

test: give each Tailwind render its own cache key, never the clock - #500

Open
YevheniiKotyrlo wants to merge 1 commit into
nativewind:mainfrom
YevheniiKotyrlo:fix/tailwind-test-cache-key
Open

YevheniiKotyrlo wants to merge 1 commit into
nativewind:mainfrom
YevheniiKotyrlo:fix/tailwind-test-cache-key

Conversation

@YevheniiKotyrlo

Copy link
Copy Markdown
Contributor

Problem

src/__tests__/vendor/tailwind/_tailwind.tsx passes tailwind({ base: Date.now().toString() }) so that renders do not share Tailwind's compiler cache. Two renders that start in the same millisecond get the same base, and the second compiles against the first's stylesheet, so its class renders no style. In a full yarn test run a random Tailwind case fails this way and passes alone: I hit Layout - Top Right Bottom Left › left-1, Sizing - Height › h-px and Layout - Clear › clear-left, each rendering { props: {} }.

Solution

A counter gives every render a base of its own.

Tests

src/__tests__/vendor/tailwind/harness.test.tsx freezes Date.now() and renders left-0, then left-1. On main the second renders { props: {} }; here each renders its own value.

Verification

On Ubuntu with the workflow's steps - build, lint, typecheck, yarn test, node --test node/__tests__/*.mjs, both library builds, the web export, the unstaged-changes checks and commitlint - everything passes.

The harness passed Date.now() as Tailwind's base to keep renders from
sharing its compiler cache, so two renders that start in the same
millisecond shared it, and the second compiled against the first's
stylesheet: a random Tailwind case failed in a full run and passed alone.
A counter gives every render a base of its own.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant