Polymer not Defined in Web Component Tester

237 Views Asked by At

I am trying to run two tests with web-component-tester interactively on a Polymer 2 project in Chrome v69, web-component-test v 6.5.0, and webcomponentsjs v 2.1.3. The first super basic test passes, and the second fails with the following error:

Error: Polymer is not defined flush at shop-home.test.html:36

<html>
<head>
  <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
  <title>shop-home</title>
  <script src="/bower_components/webcomponentsjs/webcomponents-lite.js"></script>
  <script>void(0)</script>
  <script src="/bower_components/web-component-tester/browser.js"></script>
  <link rel="import" href="/bower_components/test-fixture/test-fixture.html">
 <link rel="import" href="../shop-home.html">

</head>
<body>

  <test-fixture id="basic">
    <template>
       <shop-home></shop-home>
    </template>
  </test-fixture>

  <script>
    suite('shop-home tests', () => {
      var home;

      setup(() => {
        home = fixture('basic');
      });

      test('super basic test', (done) => {
        flush(() => {
          console.log('what a great test')
          done();
        });
      });

      test('load mission statement', (done) => {
        flush(() => {
          let ms = Polymer.dom(home.root).querySelector('mission-statement');
          assert.exists(ms, 'mission statement is neither `null` nor `undefined`');
      done();
    });
  });

});

When running via the command line the error gives more detail:

Error: Error thrown outside of test function: document.getElementById(fixtureId).create is not a function. (In 'document.getElementById(fixtureId).create(model)', 'document.getElementById(fixtureId).create' is undefined) at shop-home.html:25, 1 failed tests, Error thrown outside of test function: document.getElementById(...).create is not a function at shop-home.html:25

How can I prevent this and run a proper unit test?

0

There are 0 best solutions below