Git Product home page Git Product logo

Comments (4)

FrontendJesus avatar FrontendJesus commented on July 24, 2024 1

Adding that code into the beforeEach of the failing component test fixed it. Thanks

from simple-keyboard.

hodgef avatar hodgef commented on July 24, 2024

Hello @digilab2017,

KEYBOARD_DOM_ERROR means that <div class="simple-keyboard"></div> was not found in the dom at instantiation.

To make the error go away, simple-keyboard needs to find that element when it's run.
https://github.com/hodgef/simple-keyboard/blob/master/src/lib/components/Keyboard.js#L115

You can have a look at my unit tests here:
https://github.com/hodgef/simple-keyboard/blob/master/src/lib/components/tests/Keyboard.test.js#L15

As you see, testUtil.setDOM(); is being called, which in turn does this:

const div = document.createElement('div');
div.className += divClass || "simple-keyboard";
document.body.appendChild(div);

Angular Note: If you're using ngOnInit, use ngAfterViewInit instead, as per the following demo:
https://codesandbox.io/s/github/hodgef/angular-simple-keyboard/tree/master/?module=%2Fsrc%2Fapp%2Fapp.component.ts

Regards,
Francisco Hodge

from simple-keyboard.

andrelutza avatar andrelutza commented on July 24, 2024

Hello,
I'm having the same error, but your fix did not solve my issue. Here is my test repository: https://github.com/andrelutza/keyboard-test
Any ideas what it might be?
Thanks!

from simple-keyboard.

hodgef avatar hodgef commented on July 24, 2024

@andrelutza It's an issue with your Jest config
In your jest.config.js, find this:

moduleNameMapper: {
    '^@/(.*)$': '<rootDir>/src/$1'
},

and replace it with this

moduleNameMapper: {
    '^@/(.*)$': '<rootDir>/src/$1',
    "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "jest-transform-stub",
    "\\.(css|less)$": "jest-transform-stub"
},

from simple-keyboard.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.