wd-David / svelte-component-test-recipes

Svelte component test recipes using Vitest & Testing Library with TypeScript
156 stars 5 forks source link

Test CSS variable props #11

Open janosh opened 2 years ago

janosh commented 2 years ago

Curious if anyone has looked into testing CSS variable props. This doesn't work (even with viteConfig.test.css set to true):


test(`CSS variables are applied`, () => {
  new Component({
    target: document.body,
    props: {
      '--custom-bg-color': `green`,
    },
  })
  const div = document.querySelector(`.some-class`)
  expect(getComputedStyle(div).backgroundColor).toBe(`green`)
})