@open-wc/chai-dom-equals
Advanced tools
Comparing version 0.5.0 to 0.5.1
@@ -6,2 +6,13 @@ # Change Log | ||
## [0.5.1](https://github.com/open-wc/open-wc/tree/master/packages/chai-dom-equals/compare/@open-wc/chai-dom-equals@0.5.0...@open-wc/chai-dom-equals@0.5.1) (2018-11-30) | ||
### Bug Fixes | ||
* move documentation to READMEs of packages ([b4a0426](https://github.com/open-wc/open-wc/tree/master/packages/chai-dom-equals/commit/b4a0426)) | ||
# [0.5.0](https://github.com/open-wc/open-wc/tree/master/packages/chai-dom-equals/compare/@open-wc/chai-dom-equals@0.4.0...@open-wc/chai-dom-equals@0.5.0) (2018-11-26) | ||
@@ -8,0 +19,0 @@ |
{ | ||
"name": "@open-wc/chai-dom-equals", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"description": "Chai Plugin to compare dom and shadow dom trees. Part of open-wc recommendations", | ||
@@ -17,13 +17,13 @@ "author": "open-wc", | ||
"dependencies": { | ||
"@open-wc/semantic-dom-diff": "^0.4.0" | ||
"@open-wc/semantic-dom-diff": "^0.4.1" | ||
}, | ||
"devDependencies": { | ||
"@bundled-es-modules/chai": "^4.2.0", | ||
"@open-wc/testing-helpers": "^0.4.0", | ||
"@open-wc/testing-karma": "^0.2.0", | ||
"@open-wc/testing-karma-bs": "^0.1.0", | ||
"@open-wc/testing-wallaby": "^0.1.3", | ||
"@open-wc/testing-helpers": "^0.4.1", | ||
"@open-wc/testing-karma": "^0.2.1", | ||
"@open-wc/testing-karma-bs": "^0.1.1", | ||
"@open-wc/testing-wallaby": "^0.1.4", | ||
"mocha": "^5.0.0" | ||
}, | ||
"gitHead": "91d6d70f98a9dbf142623768b7c97dce9c9db090" | ||
"gitHead": "66a2109658155192522ed92f365a2652029c3ce0" | ||
} |
@@ -1,6 +0,6 @@ | ||
# Open Web Component Recommendations Chai Plugin to compare dom and shadowDom trees | ||
# Testing Chai Dom Equals | ||
> Part of Open Web Component Recommendations [open-wc](https://github.com/open-wc/open-wc/) | ||
> Part of Open Web Component Recommendation [open-wc](https://github.com/open-wc/open-wc/) Recommendation [open-wc](https://github.com/open-wc/open-wc/) | ||
We want to provide a good set of default on how to vasilitate your web component. | ||
We want to provide a good set of defaults on how to facilitate your web component. | ||
@@ -10,1 +10,47 @@ [![CircleCI](https://circleci.com/gh/open-wc/open-wc.svg?style=shield)](https://circleci.com/gh/open-wc/open-wc) | ||
[![Renovate enabled](https://img.shields.io/badge/renovate-enabled-brightgreen.svg)](https://renovatebot.com/) | ||
Comparing dom literally is usually not what you want when testing components. | ||
Additionally, when using ShadyDOM and/or ShadyCSS there will be additional classes you are not interested in. | ||
::: tip Info | ||
This is part of the default [open-wc](https://open-wc.org/) recommendation | ||
::: | ||
## Manual Setup | ||
Add the following after chai is loaded | ||
```js | ||
import { chai } from '@bundled-es-modules/chai'; | ||
import { chaiDomEquals } from '@open-wc/chai-dom-equals'; | ||
chai.use(chaiDomEquals); | ||
``` | ||
## Test dom of an element | ||
```js | ||
it('has the following dom', async () => { | ||
const el = await fixture(`<div><!-- comment --><h1>${'Hey'} </h1> </div>`); | ||
expect(el).dom.to.equal('<div><!-- comment --><h1>Hey </h1> </div>'); | ||
expect(el).dom.to.semantically.equal('<div><h1>Hey</h1></div>'); | ||
}); | ||
``` | ||
## Test shadow dom of an element | ||
```js | ||
it('has the following shadow dom', async () => { | ||
const tag = defineCE(class extends HTMLElement { | ||
constructor() { | ||
super(); | ||
this.attachShadow({ mode: 'open' }); | ||
} | ||
connectedCallback() { | ||
this.shadowRoot.innerHTML = '<p> shadow content</p> <!-- comment --> <slot></slot>'; | ||
} | ||
}); | ||
const el = await fixture(`<${tag}></${tag}>`); | ||
expect(el).shadowDom.to.equal('<p> shadow content</p> <!-- comment --> <slot></slot>'); | ||
expect(el).shadowDom.to.semantically.equal('<p>shadow content</p><slot>'); | ||
}); | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13170
56