Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"ReferenceError: FontFace is not defined" during test runs #5546

Closed
zach-thrivetribe opened this issue Mar 14, 2022 · 3 comments
Closed

"ReferenceError: FontFace is not defined" during test runs #5546

zach-thrivetribe opened this issue Mar 14, 2022 · 3 comments
Labels

Comments

@zach-thrivetribe
Copy link

zach-thrivetribe commented Mar 14, 2022

Describe the bug

Running bit test throws a ReferenceError: FontFace is not defined error when testing a component that uses the CSS Font Loading API.

Steps to Reproduce

  1. run bit test on a component that uses the font loading API

Expected Behavior

Successful run of the unit tests

Screenshots, exceptions and logs

` ReferenceError: FontFace is not defined

  1 | export const loadBebasNeueFont = () => {
> 2 |   var bebasNeue = new FontFace("Bebas Neue", "url(https://fonts.gstatic.com/s/bebasneue/v8/JTUSjIg69CK48gW7PXoo9Wlhyw.woff2)", {weight: "400"});
    |                   ^
  3 |
  4 |   bebasNeue
  5 |     .load()`### Specifications* Bit version: 0.0.603
  • Workspace type: harmony
  • Node version: 14.17.3
  • npm / yarn version: 6.14.13
  • Platform: windows 10
"teambit.dependencies/dependency-resolver": {
    /**
     * choose the package manager for Bit to use. you can choose between 'yarn', 'pnpm'
     */
    "packageManager": "teambit.dependencies/pnpm",
    "policy": {
      "dependencies": {
        "@testing-library/dom": "8.11.3",
        "@testing-library/react": "12.1.3",
        "@testing-library/user-event": "13.5.0",
@zach-thrivetribe
Copy link
Author

Forgot to mention that the Font Loading API works perfectly fine outside of the tests, I am able to tag and export components that use it just fine, but when put in the tests it throws those errors.

@NitsanCohen770
Copy link
Contributor

resolved in new envs api

@emersonthis
Copy link

@NitsanCohen770 Can you point me towards how you solved this? I'm running into what sounds like the same issue on a different project: jsdom / happy-dom don't support APIs like FontFace

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants