https://github.com/jagreehal/stencil-how-to-test-components
Examples of how to test Stencil components
https://github.com/jagreehal/stencil-how-to-test-components
jest snapshot-testing stenciljs testing
Last synced: 2 months ago
JSON representation
Examples of how to test Stencil components
- Host: GitHub
- URL: https://github.com/jagreehal/stencil-how-to-test-components
- Owner: jagreehal
- Created: 2018-03-01T19:59:59.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2025-11-21T20:52:59.000Z (6 months ago)
- Last Synced: 2025-11-21T22:21:45.770Z (6 months ago)
- Topics: jest, snapshot-testing, stenciljs, testing
- Language: TypeScript
- Homepage:
- Size: 729 KB
- Stars: 69
- Watchers: 1
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Examples of how to test Stencil Components using Jest and Puppeteer

Examples of how to test [Stencil](https://stenciljs.com) components... both what works and doesn't!
## [EventEmitter](https://stenciljs.com/docs/events)
✅ can assert events have been raised
## [Methods](https://stenciljs.com/docs/decorators)
✅ can call methods on elements
## [Props](https://stenciljs.com/docs/decorators)
✅ can set props on element
✅ can change prop value
## Snapshots
📷 can use snapshots
## Added bonus!
For VSCode users checkout [launch.json](.vscode/launch.json) for debugging tests
```js
{
"version": "0.2.0",
"configurations": [{
"type": "node",
"request": "launch",
"name": "E2E Test Current File",
"cwd": "${workspaceFolder}",
"program": "${workspaceFolder}/node_modules/.bin/stencil",
"args": ["test", "--e2e", "${relativeFile}"],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"disableOptimisticBPs": true,
"skipFiles": [
"${workspaceFolder}/node_modules/**/*.js",
"/**/*.js"
]
},
{
"type": "node",
"request": "launch",
"name": "Spec Test Current File",
"cwd": "${workspaceFolder}",
"program": "${workspaceFolder}/node_modules/.bin/stencil",
"args": ["test", "--spec", "${relativeFile}"],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"disableOptimisticBPs": true,
"skipFiles": [
"${workspaceFolder}/node_modules/**/*.js",
"/**/*.js"
]
}
]
}
```