Hi all!
This release is focused on providing some small quality of life improvements to the property-based testing features within Pineapple.
There are two main additions to the technology:
Namespaces
/**
* Creates the static values for use in various scenarios in our codebase.
* @pineapple_define friends
*/
function define () {
return {
kevin: { /* ... */ },
shane: { /* ... */ },
emily: { /* ... */ }
}
}
/**
* #friends.emily, #friends.shane returns 'Battle won!'
* #friends.shane, #friends.kevin returns 'Battle draw!'
*/
function fight (attacker, defender) {
/* ... */
}
Namespaces might make it simpler to set up various generators & static values that you might wish to use throughout your tests.
Better Constant Detection
When you set up definitions in Pineapple, the testing framework will do its best to try to keep track of whether your "arbitrary expression" is actually constant.
This prevents a bunch of duplicate tests from taking place, particularly when it would be annoying (like in snapshots).
Previously, when one would try the following:
/**
* @pineapple_define
*/
function define () {
return { age: 17 }
}
/**
* @test { name: 'Kevin', age: #age }
* The above would not be detected as static in v0.9.0,
* but will be in v0.9.1
*/
function setupAccount({ name, age }) {
/* ... */
}
/**
* @test #age returns false
* The above will be detected as constant in both v0.9.0 and v0.9.1
*/
function isAmericanDrinkingAge (age) {
return age >= 21
}
Pineapple would not be able to detect that the expression { name: 'Kevin', age: #age }
was actually a constant expression. However, if you used #age
outside of a structure as seen in the second example, it would work!
To make developer's lives easier, Pineapple has been improved to try to do a better job of detecting constant structures.