Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to delete the data sources from a test to the other? #426

Open
clauBv23 opened this issue Apr 6, 2024 · 1 comment
Open

Comments

@clauBv23
Copy link

clauBv23 commented Apr 6, 2024

Hi there:

I'm trying to test some logic that involves the creation of new templates. But when checking the created templates from one test to the other they are not being initialized and continue existing. For cleaning the store exists the clearStore I was wondering if there is a similar function for creating the data source.

I mean, let's say I have something like this:

describe('handle....', () => {
  afterAll(() => {
    clearStore();
      });

  test('it should work on way 1 ', () => {
        ... some code here 
        assert.dataSourceCount('NewTemplate', 1);   // want to check the template was created 
        ... other checks
   });

   test('it should work on way 2 ', () => {
        ... some code here 
        assert.dataSourceCount('NewTemplate', 1);     // want to check the template was created but at this point, the template from 
        ... other checks                             //     the previous test will exist so there will be 2 templates instead of 1
   });
});

I would like to be able to clean the data sources to test their existence properly, having a function like clearStore to clear the data sources clearDataSources will help.

Thanks

@kaihiroi
Copy link

Hello!
I'm not sure if this will be helpful, but I've encountered a similar issue.
In the end, I found that using dataSourceMock for testing worked well for me.
https://thegraph.com/docs/en/developing/unit-testing-framework/#testing-dynamic-data-sources

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

No branches or pull requests

2 participants