Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@open-wc/testing-helpers

Package Overview
Dependencies
Maintainers
2
Versions
156
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@open-wc/testing-helpers - npm Package Compare versions

Comparing version 0.7.11 to 0.7.12

elementUpdated.js

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

## [0.7.12](https://github.com/open-wc/open-wc/tree/master/packages/testing-helpers/compare/@open-wc/testing-helpers@0.7.11...@open-wc/testing-helpers@0.7.12) (2019-02-04)
### Bug Fixes
* **testing-helpers:** add `await elementUpdated(el)` supports stencil ([c442f21](https://github.com/open-wc/open-wc/tree/master/packages/testing-helpers/commit/c442f21))
## [0.7.11](https://github.com/open-wc/open-wc/tree/master/packages/testing-helpers/compare/@open-wc/testing-helpers@0.7.10...@open-wc/testing-helpers@0.7.11) (2019-02-02)

@@ -8,0 +19,0 @@

1

index-no-side-effects.js

@@ -15,1 +15,2 @@ export { html, unsafeStatic } from './lit-html.js';

export { cachedWrappers, fixtureWrapper, fixtureCleanup } from './fixtureWrapper.js';
export { elementUpdated } from './elementUpdated.js';

@@ -15,1 +15,2 @@ export { html, unsafeStatic } from './lit-html.js';

export { cachedWrappers, fixtureWrapper, fixtureCleanup } from './fixtureWrapper.js';
export { elementUpdated } from './elementUpdated.js';

9

litFixture.js
import { fixtureWrapper } from './fixtureWrapper.js';
import { render } from './lit-html.js';
import { nextFrame } from './helpers.js';
import { elementUpdated } from './elementUpdated.js';

@@ -25,9 +25,4 @@ /**

const el = litFixtureSync(template);
const update = el.updateComplete;
if (typeof update === 'object' && Promise.resolve(update) === update) {
await update;
} else {
await nextFrame();
}
await elementUpdated(el);
return el;
}
{
"name": "@open-wc/testing-helpers",
"version": "0.7.11",
"version": "0.7.12",
"description": "Testing Helpers following open-wc recommendations",

@@ -32,3 +32,3 @@ "author": "open-wc",

},
"gitHead": "d32e8443a74121f4fbcb775669deab80633b8fd3"
"gitHead": "c09ae19c31e87f836982bb3b9ee5539db8331346"
}

@@ -73,16 +73,35 @@ # Testing Helpers

## Timings
If you need to wait for multiple elements to update you can use `nextFrame`.
By default fixture awaits the elements "update complete" Promise.
- for [lit-element](https://github.com/polymer/lit-element) that is `el.updateComplete`;
- for [stencil](https://github.com/ionic-team/stencil/) that is `el.componentOnReady()`;
If none of those specfic Promise hooks are found, it will wait for one frame via `await nextFrame()`.<br>
**Note**: this does not guarantee that the element is done rendering - it just waits for the next JavaScript tick.
Essentially, `fixture` creates a synchronous fixture, then waits for the element to finish updating, checking `updateComplete` first, then falling back to `componentReady()`, and `nextFrame()` as a last resort.
This way, you can write your tests more succinctly, without having to explicitly `await` those hooks yourself.
```js
import { nextFrame, aTimeout, html, fixture } from '@open-wc/testing-helpers';
const el = await fixture(html`<my-el .foo=${'bar'}></my-el>`);
expect(el.foo).to.equal('bar');
el.foo = 'baz';
// vs
const el = fixtureSync(html`<my-el .foo=${'bar'}></my-el>`);
await elementUpdated(el);
expect(el.foo).to.equal('bar');
```
### nextFrame
Uses `requestAnimationFrame` to wait for the next frame.
```js
await nextFrame();
// or as an alternative us timeout
// await aTimeout(10); // would wait 10ms
expect(el.shadowRoot.querySelector('#foo').innerText).to.equal('baz');
```
### aTimeout
Waits for `x` ms via `setTimeout`;
```js
await aTimeout(10); // would wait 10ms
```
## Fixture Cleanup

@@ -89,0 +108,0 @@ By default, if you import anything via `import { ... } from '@open-wc/testing-helpers';`, it will automatically register a side-effect that cleans up your fixtures.

@@ -1,3 +0,3 @@

import { nextFrame } from './helpers.js';
import { fixtureWrapper } from './fixtureWrapper.js';
import { elementUpdated } from './elementUpdated.js';

@@ -26,9 +26,4 @@ /**

const el = stringFixtureSync(template);
const update = el.updateComplete;
if (typeof update === 'object' && Promise.resolve(update) === update) {
await update;
} else {
await nextFrame();
}
await elementUpdated(el);
return el;
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc