Skip to content

How should I use addFunctionSerializer when using test? #1278

Answered by askoufis
black7375 asked this question in Q&A
Discussion options

You must be logged in to vote

Calling setFileScope before myStyle seems to fix it, though it doesn't seem to actually do anything with the filescope you provide. The plugin usually handles this in regular code, but I think due to that way tests are executed this doesn't occur, so you have to do it manually.

import { setFileScope } from "@vanilla-extract/css/fileScope";

if (import.meta.vitest) {
  const { it, expect } = import.meta.vitest;

  it("Anonymous AtRules", () => {
    const rules: MyStyleRule = {
      animationName: {
        from: {
          opacity: 0
        },
        "50%": {
          opacity: 0.3
        },
        to: {
          opacity: 1
        }
      }
    };

    setFileScope('foo');

    ex…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@black7375
Comment options

@askoufis
Comment options

Answer selected by black7375
@black7375
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants