Polymer / tools

Polymer Tools Monorepo
BSD 3-Clause "New" or "Revised" License
430 stars 200 forks source link

Error: fixture is not a function #3098

Closed lukasoppermann closed 2 years ago

lukasoppermann commented 8 years ago

Hey, I don't know what I am doing wrong, but I always get:

Error: fixture is not a function Context. at basic-test.html:20

This is my basic-html.test

<!doctype html>
<html>
    <head>
    <meta charset="utf-8">
    <script src="../bower_components/webcomponentsjs/webcomponents-lite.js"></script>
    <script src="../bower_components/web-component-tester/browser.js"></script>
    <script src="../dist/material-input.js"></script>
    </head>
    <body>
       <test-fixture id="fixture">
            <template>
                <material-input value="test"></material-input>
            </template>
        </test-fixture>

    <script>
        suite('<material-input>', function() {
            var el;

            setup(function() {
                el = fixture('fixture');
            });

            // a11ySuite('fixture');

            test('defines the "value" property', function() {
                assert.equal(el.value, 'test');
            });

Using this works fine:

<material-input value="test" id="fixture"></material-input>
el = document.getElementById('fixture');
lukasoppermann commented 8 years ago

@rictic any idea what I am doing wrong? I seem to be missing some kind of import? Is this because I am testing vanilla js elements and not importing polymer?

brason commented 7 years ago

Had the same problem. Apparently you can't name your fixture 'fixture'.

lukasoppermann commented 7 years ago

So how does your test look like?

MajorBreakfast commented 6 years ago

@brason Thx!

So, I did some investigation and here's why: Elements with an id get automatically a global variable http://2ality.com/2012/08/ids-are-global.html That means when you call it fixture, the variable replaces the fixture() function. I didn't see that coming :D

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.