PricingBlog

Practices for creating test data for dynamic context while working in the editor.

  • alfred_66594-1279496253981593630

    Alfred

    1 year ago

    I have tried to create a simple global formula for providing test data to components that rely on dynamic context data. I'm using this function for things like API calls, local storage, and page parameters to have some 'dummy data' while working on my components. My question is: would this be considered bad practice, or are there alternative approaches I should consider?
    1279496254518329436-image.png
  • drhariri-1279561693910929468

    DrHariri

    1 year ago

    I am also interested in knowing best ways to handle having some context data 👍
  • tomthebigtree-1281573600515723309

    Tom Ireland

    1 year ago

    That’s an interesting approach, Alfred. Personally speaking, I would always be cautious with keeping test data in the app just in case it makes its way to the db, local storage, etc., somehow in production. I tend to create test data in a branch when working on something (it’s often needed if the data is dynamic) and then remove it prior to publishing. This way, I know it’s never going to reach the main branch. You could also have a branch that always contains the test data and copy/paste when working on something. Probably a few ways to skin a cat there. Alternatively, you could use your db to store test data and utilise that. It’s hard to tell as there’s no specific use-case but I hope that’s helpful.
  • tomthebigtree-1281575477378814085

    Tom Ireland

    1 year ago

    Also, I know the toddle team uses feature flags (not exactly sure how, so might be worth asking the question) to manage new functionality, which probably does have some test data when developing.
    👍1
  • tomthebigtree-1281576077600489644

    Tom Ireland

    1 year ago

    I asked ChatGPT and got this, which confirms feature flags, conditional logic or git branches is probably a good approach.
    👍1