Releases: helpscout/helix
v0.2.0
v0.1.2
Seeding: Generating different + consistent values for multiple fixtures
This update fixes the generate
method for HelixSpec
which ensures that if
multiple fixtures are being generated, then all of those fixtures use a
different seed index.
This allows for multiple fixtures to be consistently seeded, but have different
seeded results.
The generate accepts the initial seed value (e.g. 2), and increments it for
every iteration that it generates (e.g. 2, 3, 4, 5).
Resolves: #20
v0.1.1
Helix - v0.0.14
Fix oneOf
export so that hs-app can import that helper
Change how we export oneOf
to no longer use the export * from './helpers'
format, since that way does not work properly with hs-app's webpack config (since tree shaking doesn't work quite right out of the box we had to shim the helix webpack config)
Thanks to @brettjonesdev !
Helix - v0.0.13
Add beforeGenerate and afterGenerate hooks
This update adds two new hook methods to HelixSpec
: beforeGenerate
and afterGenerate
.
These hooks allow you easily to adjust the shape/fixture data of
your specs, which can be handy for create alternate specs.
Example: afterGenerate()
const Dinosaur = createSpec({
id: faker.random.number(),
name: faker.name.firstName(),
location: faker.address.country()
})
Dinosaur.afterGenerate(data => {
const { name } = data
return {
name,
location: 'Mexico',
status: 'Happy',
email: '[email protected]'
}
})
Dinosaur.generate()
// {
// name: 'Alice',
// location: 'Mexico'
// status: 'Happy',
// email: '[email protected]'
// }
cc'ing @brettjonesdev ;)
Resolves: #11
Helix - v0.0.12
Fix bug where generate(0)
returns a single spec instance instead of empty array
Helix - v0.0.11
Add new derived()
function for better computeds
🍐 with @alisdair to add a new function that allows you to create
computed values based on existing data within the shape of the Spec.
Example
const Spec = createSpec({
fname: () => 'Alice',
lname: () => 'Baker',
name: derived(({ fname, lname }) => `${fname} ${lname}`)
})
const fixture = Spec.generate()
Output
{
fname: 'Alice',
lname: 'Baker',
name: 'Alice Baker'
}
faker.computed()
has been deprecated in favour of the new derived()
function.
Helix - v0.0.10
Add oneOf()
helper function
Add oneOf()
helper to create specs which return variable shapes.
Example
import { oneOf, createSpec, faker } from '@helpscout/helix'
const Tyrannosaurus = createSpec({
id: faker.random.number(),
type: 'meateater',
name: faker.name.firstName()
})
const Stegosaurus = createSpec({
id: faker.random.number(),
type: 'planteater',
name: faker.name.firstName()
})
const Dinosaur = oneOf([Tyrannosaurus, Stegosaurus])
Dinosaur.generate()
// Instance of either stegasaurus or tyrannosaurus
Read more here
Added by @brettjonesdev ❤️
Helix - v0.0.9
Fix bug where Spec.generate(0, 3)
returns a non-array if the random count is 0
Spec.generate(0,3)
wasn't returning []
when the random count was 0. Was treating the same as if we called Spec.generate()
and returned a single spec instance, which is wrong.
Helix - v0.0.8
Support single value HelixSpecs
Feature
This PR allows the creation of HelixSpecs which return a single value. For example:
const UserType = new HelixSpec(faker.random.arrayElement(['user', 'guest', 'admin']))
const User = new HelixSpec({
id: faker.random.number(),
name: faker.name.firstName(),
location: faker.address.country(),
type: UserType
})