Skip to content

Allow fabricator to access current state#104

Open
liamo94 wants to merge 2 commits intomainfrom
liam/fabricator-function
Open

Allow fabricator to access current state#104
liamo94 wants to merge 2 commits intomainfrom
liam/fabricator-function

Conversation

@liamo94
Copy link

@liamo94 liamo94 commented Jan 17, 2025

Added a way to access current state of the fabricated object. While this same behaviour can achieved by using more fabricators and consts, this should give a little more flexibility in the way we use it

@liamo94 liamo94 requested a review from robmosca January 17, 2025 10:37
@robmosca
Copy link

I got a reminder about this PR. Is this still something useful @liamo94? Maybe @Gpx (the original author of this package) wants to check?

@liamo94
Copy link
Author

liamo94 commented Feb 17, 2026

I got a reminder about this PR. Is this still something useful @liamo94? Maybe @Gpx (the original author of this package) wants to check?

Ah forgot about this 😂 , yeah so this was useful for us for like deep objects we fabricate, where say we want the segment id be that of the parent leg. It would just mean we can inline it, so rather than:

const legId = uuid();
const segment = segmentFabricator({ legId }})
const leg = legFabricator({ id: legId, segment }})

we could do:

const leg = legFabricator(leg => ({
  ...leg,
  segment: segmentFabricator({ legId: leg.id }})
})

This is a simple case, but we have use cases where we need to make sure say text for child properties matches those further up the chain

@liamo94 liamo94 marked this pull request as ready for review February 17, 2026 10:30
Copy link

@unblocked unblocked bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found.

About Unblocked

Unblocked has been set up to automatically review your team's pull requests to identify genuine bugs and issues.

📖 Documentation — Learn more in our docs.

💬 Ask questions — Mention @unblocked to request a review or summary, or ask follow-up questions about your code.

👍 Give feedback — React to comments with 👍 or 👎 to help us improve.

⚙️ Customize — Adjust settings in your preferences.

@liamo94 liamo94 force-pushed the liam/fabricator-function branch from 0584e4a to d7c7217 Compare February 18, 2026 11:51
@liamo94 liamo94 requested a review from Gpx February 18, 2026 11:54
@liamo94 liamo94 changed the title [NO_JIRA] Allow fabricator to access current state Allow fabricator to access current state Feb 18, 2026
@liamo94 liamo94 force-pushed the liam/fabricator-function branch from 52b2aa6 to b3cb147 Compare February 18, 2026 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments