bower install
- open test.html in your browser
- Watch the window title
Last active
April 24, 2017 16:03
-
-
Save tpluscode/8f856398b3305d73885015a3fb67abb1 to your computer and use it in GitHub Desktop.
Example of Web Component Tester with bound fixture
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bower_components/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "wct-so-test", | |
"description": "", | |
"main": "", | |
"authors": [ | |
"tpluscode" | |
], | |
"license": "MIT", | |
"moduleType": [], | |
"homepage": "", | |
"private": true, | |
"ignore": [ | |
"**/.*", | |
"node_modules", | |
"bower_components", | |
"test", | |
"tests" | |
], | |
"devDependencies": { | |
"web-component-tester": "~4.3.1" | |
}, | |
"dependencies": { | |
"polymer": "polymer/polymer#~1.6.0" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<head> | |
<script src="bower_components/webcomponentsjs/webcomponents.min.js"></script> | |
<link rel="import" href="bower_components/polymer/polymer.html"/> | |
<script src="bower_components/web-component-tester/browser.js"></script> | |
</head> | |
<html> | |
<dom-module id="my-element"> | |
<template> | |
<style> | |
:host { | |
display: block; | |
box-sizing: border-box; | |
} | |
</style> | |
<div id="txt-url" class="card-content">{{captureUrl}}</div> | |
</template> | |
<script> | |
Polymer({ | |
is: 'my-element', | |
properties: {captureUrl: String} | |
}); | |
</script> | |
</dom-module> | |
<test-fixture id="my-element-fixture"> | |
<template is="dom-template"> | |
<my-element capture-url="{{captureUrl}}"> | |
<h2>seed-element</h2> | |
</my-element> | |
</template> | |
</test-fixture> | |
<script> | |
suite('<my-element>', function () { | |
var myEl; | |
setup(function () { | |
myEl = fixture('my-element-fixture', {captureUrl: 'the url'}); | |
}); | |
test('heading is captureUrl', function () { | |
var urlDiv = myEl.$$('#txt-url'); | |
// this will obviously fail, but used for logging purposes | |
assert.equal(urlDiv.textContent, 'the url'); | |
}); | |
}); | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment