lundi 24 septembre 2018

"test is not defined" jest/expect on client side

I get "test is not defined" Uncaught ReferenceError on the browser.

I dont use ESLING, which according to [this link][1] is the solution to "test is not defined". "test" which is a global in jest/expect testing library, it is expected to be available after the including the expect.min.js file in the test.html

In that case what could be the other reasons and their solution.

here is my code:
    <script src="https://unpkg.com/expect@%3C21/umd/expect.min.js"></script>
    <script src='script.js'></script>
    <script>
      test('myTest', () => {
        a = {}
        b = {}
        a.rating = 1
        b.rating = 2
        expect(sortAlgo(a,b)).toBe(1)
      })
   </script>

  [1]: https://stackoverflow.com/questions/44479207/prevent-test-expect-etc-is-not-defined-errors-when-using-jest/44479250

Aucun commentaire:

Enregistrer un commentaire