Skip to content

Releases: thoughtbot/fishery

2.2.2

04 Mar 22:19
Compare
Choose a tag to compare

Bugfixes

  • Don't modify params object when building #89

2.2.1

04 Mar 16:48
Compare
Choose a tag to compare

Fixes

  • Fix issue with deep merging for properties typed as Date. #94

Features

  • Switch to Rollup for builds, add UMD and ES Modules output #85

Note: might have been an issue with the 2.2.0 release not being properly built. Please use 2.2.1 instead.

2.1.0

20 Nov 04:15
Compare
Choose a tag to compare

Fixes

  • Fix bugs in DeepPartial type definition that is used when merging params (#78)

2.0.0

20 Nov 04:10
Compare
Choose a tag to compare

Features

  • Allow specifying different return type to create (#74)

Breaking changes

  • Only one onCreate can exist for a factory. If multiple onCreate are needed, use the new afterCreate

1.4.0

02 Jul 18:23
Compare
Choose a tag to compare

Fixes

  • Fix param merge behavior when passing undefined (#44)

1.3.1

14 May 21:46
Compare
Choose a tag to compare

Fixes

  • Fix param merging so eep merge occurs with params supplied via traits (#59)

1.3.0

14 May 14:21
Compare
Choose a tag to compare

Fixes

  • Share sequence between extended factories instead of sequences diverging (#51)

Bugfix: Fix merge behavior of arrays

30 Jul 01:05
Compare
Choose a tag to compare

Fixes a bug where building a factory with an empty array was not overriding a non-empty array if it was defined that way in a factory:

const elementsFactory = Factory.define<Elements>(() => ({
  elements: ["STRING"],
}));

elementsFactory.build({ elements: [] }));
// { elements: ["STRING"] }

Now, when passing an array to myFactory.build(), that array fully overrides the object defined in the factory. There is no partial/deep merging of arrays. The typing of params in the factory now also reflect this. This should not be an issue for most users, as the existing merging of arrays was not documented and did not behave as most would expect.

See #38 for more information.

Rename afterCreate to afterBuild, remove factory registration requirement

29 Jun 01:48
Compare
Choose a tag to compare

This release includes three breaking changes. Updating your code should be fairly mechanical using the guide below:

afterCreate renamed to afterBuild

As the heading suggests, the afterCreate function that can be accessed in factories and the afterCreate factory extension function have been renamed to afterBuild (PR). To update your code, just replace all instances of afterCreate with afterBuild like shown below:

-  Factory.define(({ afterCreate }) => { ... })
+  Factory.define(({ afterBuild }) => { ... })
-  myFactory.afterCreate(object => { ... })
+  myFactory.afterBuild(object => { ... })

Removed unnecessary factories registration and injection

Fishery no longer requires (or provides a mechanism for) users to register their factories together, and factory definitions no longer take a Factories type parameter or accept a factories argument. For more info on this change, see the PR.

To update your code, make the following changes:

Remove register call

-  const factories = register({ myFactory, myOtherFactory })
+  const factories = { myFactory, myOtherFactory }

Replace defineUnregistered with define

Since factory registration is no longer required, there is no longer a concept of "unregistered" factories. Just use define.

-  Factory.defineUnregistered(...)
+  Factory.define(...)

Remove second type parameter from Factory.define and any uses of factories in the factory

If you need to use another factory in your factory, just import it directly. For more info, see the readme.

- Factory.define<User, Factories, UserTransientParams(({ factories }) => { ... })
+ Factory.define<User, UserTransientParams(() => { ... }_

Sequences now start at 1 instead of 0

Sequences now start at 1 instead of 0. A factory.rewindSequence() function was also added that resets the factory's sequence counter back to 1.

Factory extension and traits API

08 Jun 16:42
Compare
Choose a tag to compare

This adds mechanisms for extending factories and adding convenience methods to factories to simplify building complex objects. For more information, see the PR where this was implemented.