site-smoke-test
v1.0.0-beta.1
Published
Site Smoke Test is a CLI tool which looks at a website sitemap, and uses Playwright to ensure that no errors are thrown on each of the pages.
Downloads
5
Readme
Site Smoke Test
Site Smoke Test is a CLI tool which looks at a website sitemap, and uses Playwright to ensure that no errors are thrown on each of the pages.
Installation
To use, install the NPM package globally:
npm install -g site-smoke-test
Then, once installed - run site-smoke-test
to see all available options.
Basic Usage
To use the tool, pass through the URL to your website. You can also pass through a direct URL to your sitemap.xml
file.
site-smoke-test https://your-website.com
Alternatively, you can use the --urls
flag to define a series of URLs.
site-smoke-test --urls https://example.com https://example.com/test
Advanced Usage
Reporting
You can customise how the reports are generated by passing through the names of each report using the --reporters
flag:
site-smoke-test https://your-website.com/sitemap.xml --reporters console junit
Configuration File
You can use a configuration file named site-smoke-test.config.(json|yml|js)
to include configuration for the tool.
{
"sitemapURL": "https://your-website.com/sitemap.xml",
"reporters": ["console", "junit"]
}
Configuration Hooks
These hooks are called at specific times while the tool is running. In order for you to use them, you need to use a site-smoke-test.config.js
file.
module.exports = {
sitemapURL: 'https://your-website.com/sitemap.xml',
beforeAll: (tests) => {
// Before all of the tests are ran, log out the test object
console.log(tests);
}
}
beforeAll(tests: Tests[])
The beforeAll
hook is called before all of the tests are ran.
afterAll(tests: Tests[])
The afterAll
hook is called after all of the tests are ran.
beforePage(test: Test)
The beforePage
hook is called before a test is ran.
afterPage(test: Test)
The afterPage
hook is called after a test is ran.
You can also do things like modify the result of the test if required.
module.exports = {
// ...
afterPage: (test) => {
// Here you might want to add some logic that would make the test pass or fail, such as if the test is on a specific path.
// Force all of the tests to pass
test.pass();
// Alternatively - you can force all of the tests to fail.
test.fail();
}
}
Development
Todo
There are a few things I'd like to do before I fully release the project - these include:
- [x] - Additional Reporters
- [x] - Playwright customisation
- [ ] - Plugin/Extension support
- [x] - Add unit tests for the tool