Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/anthonkendel/jest-serializer-pug
HTML to Pug Jest snapshot serializer
https://github.com/anthonkendel/jest-serializer-pug
anthonkendel jest jest-snapshot-serializer pug snapshot snapshot-testing
Last synced: 19 days ago
JSON representation
HTML to Pug Jest snapshot serializer
- Host: GitHub
- URL: https://github.com/anthonkendel/jest-serializer-pug
- Owner: anthonkendel
- License: mit
- Created: 2020-01-20T18:54:39.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-12-04T19:16:43.000Z (about 3 years ago)
- Last Synced: 2024-04-25T22:00:32.599Z (8 months ago)
- Topics: anthonkendel, jest, jest-snapshot-serializer, pug, snapshot, snapshot-testing
- Language: JavaScript
- Size: 2.63 MB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# [`jest-serializer-pug`](https://github.com/anthonkendel/jest-serializer-pug)
Pug Jest snapshot serializer
[![latest git version](https://img.shields.io/github/v/tag/anthonkendel/jest-serializer-pug?label=version)](https://github.com/anthonkendel/jest-serializer-pug)
[![latest npm version](https://img.shields.io/npm/v/jest-serializer-pug)](https://www.npmjs.com/package/jest-serializer-pug)
[![license](https://img.shields.io/github/license/anthonkendel/jest-serializer-pug)](https://github.com/anthonkendel/jest-serializer-pug/blob/master/LICENSE)## Installation
### Requirements
- `node` >= v10
- `npm` >= v5
- `jest` >= v22```bash
npm install --save-dev jest-serializer-pug
```## Usage
Once the `jest-serializer-pug` package is installed, you can use it by specifying the `jest-serializer-pug` serializer for the [`snapshotSerializers`](https://jestjs.io/docs/en/configuration#snapshotserializers-arraystring) property in the [Jest configuration](https://jestjs.io/docs/en/configuration).
```js
{
"snapshotSerializers": ["jest-serializer-pug"]
}
```The serializer support values that are of type [String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) or [Element](https://developer.mozilla.org/en-US/docs/Web/API/Element). Internally it uses [`html2pug`](https://github.com/izolate/html2pug) to convert HTML to Pug template.
## Example
### html
```html
Username
This username is available
Message
Yes
No
Submit
Cancel
```### pug
```pug
div
.field
label.label Username
.control.has-icons-left.has-icons-right
input.input.is-success(type="text", placeholder="Text input", value="bulma")
span.icon.is-small.is-left
i.fas.fa-user
span.icon.is-small.is-right
i.fas.fa-check
p.help.is-success This username is available
.field
label.label Message
.control
textarea.textarea(placeholder="Textarea")
.field
.control
label.checkbox
input(type="checkbox")
|
I agree to the
a(href="#") terms and conditions
.field
.control
label.radio
input(type="radio", name="question")
|
Yeslabel.radio
input(type="radio", name="question")
|
No.field.is-grouped
.control
button.button.is-link Submit
.control
button.button.is-link.is-light Cancel
```## Contributing
If you want to contribute and make our project better, your help is very welcome.
## License
[MIT © anthonkendel](https://choosealicense.com/licenses/mit/)