You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In version 1.0.10, we introduced a new behavior for the @venus-fixture annotation. Now, before each test runs, we reset the fixture DOM elements to their initial state.
Consider this example:
mycontrol.fixture.html
<ulid="my-list"><li>List Item 1</li></ul>
mycontrol.spec.js
/** * @venus-library mocha * @venus-fixture mycontrol.fixture.html */describe('my control',function(){varul=document.querySelector('#my-list');it('should add one list item',function(){varli=document.createElement('li');li.innerText='New List Item';ul.appendChild(li);expect(ul.childElementCount).to.be(1);});it('should set classname on ul',function(){ul.className='foo';expect(ul.className).to.be('foo');});});
The should set classname on ul test will fail. This is because the innerHTML of the DOM element containing the HTML fixture code is wiped out between each test.
To fix this problem, the user would need to re-select the <ul id="my-list"> element from the DOM before each test runs. The easiest way to do this, in this mocha based example, is to use a beforeEach() hook:
mycontrol.spec.js with before each hook
/** * @venus-library mocha * @venus-fixture mycontrol.fixture.html */describe('my control',function(){varul;beforeEach(function(){ul=document.querySelector('#my-list');});it('should add one list item',function(){varli=document.createElement('li');li.innerText='New List Item';ul.appendChild(li);expect(ul.childElementCount).to.be(1);});it('should set classname on ul',function(){ul.className='foo';expect(ul.className).to.be('foo');});});
We are introducing a new annotation, @venus-fixture-reset false, to disable this functionality.
The text was updated successfully, but these errors were encountered:
In version 1.0.10, we introduced a new behavior for the
@venus-fixture
annotation. Now, before each test runs, we reset the fixture DOM elements to their initial state.Consider this example:
mycontrol.fixture.html
mycontrol.spec.js
The
should set classname on ul
test will fail. This is because theinnerHTML
of the DOM element containing the HTML fixture code is wiped out between each test.To fix this problem, the user would need to re-select the
<ul id="my-list">
element from the DOM before each test runs. The easiest way to do this, in this mocha based example, is to use abeforeEach()
hook:mycontrol.spec.js with before each hook
We are introducing a new annotation,
@venus-fixture-reset false
, to disable this functionality.The text was updated successfully, but these errors were encountered: