Help forum

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

  • Alfred

    2 years 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

    2 years ago

    I am also interested in knowing best ways to handle having some context data 👍
  • Tom Ireland

    2 years 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.
  • Tom Ireland

    2 years 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
  • Tom Ireland

    2 years ago

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