Tests
Tests are a critical part of the Spruce SDLC
Creating a test is as easy as:
spruce create.test
Test Reporter
Watching Tests:
Smart mode will watch for file changes. If any changes are detected, it’ll set a 3 second timer to wait for additional changes. If no changes are detected after 3 seconds, it’ll run all tests across all files. If any tests fails, it’ll set a filter to only run the test file that failed. Once it passes, it’ll clear the filter and run all tests again.
spruce test --watchMode smart
Polish
The Polish
system is built to facilitate front-end automated testing. It is a simple, yet powerful, system that allows you to write “Polish Scripts” quickly and easily.
Creating your first Polish Script
Assuming you are already in a Skill
or module, you can create a new Polish Script by running the following command:
spruce setup.polish
Examples
Logging In
import { PolishStep } from '@sprucelabs/heartwood-polish'
const script: PolishStep[] = [
{
click: {
target: [['Field', 'phone']],
text: '555-000-0018',
},
},
{
typeText: {
target: [['Field', 'pin']],
value: '0000'
}
}
]
export default script
Clicking Buttons
When you are clicking buttons, you can click by the following:
primary
descructive
- Index (zero based)
import { PolishStep } from '@sprucelabs/heartwood-polish'
const script: PolishStep[] = [
{
click: {
target: [['button', 'primary']],
},
},
{
click: {
target: [['button', 'destructive']],
},
},
{
click: {
target: [['button', 0]],
},
},
{
click: {
target: [['button', 1]],
},
},
]
export default script
Clicking Buttons in Dialogs
import { PolishStep } from '@sprucelabs/heartwood-polish'
const script: PolishStep[] = [
{
click: {
target: ['Dialog', ['Button','primary']]
}
}
]
export default script