Closed airtonix closed 3 years ago
I will also mention that i've split jest.config.before-mobxkeystone.js
and jest.config.setup-mobxkeystone.js
in the jest config because you're don't have access to beforeEach
within the setupFiles
stage.
I've also had a look at https://github.com/xaviergonz/mobx-keystone/blob/master/packages/lib/test/commonSetup.ts and tried to imitate its use, but we still get the error/warning mentioned above.
Does it happen when jest is running in watch mode, when it runs in single run mode or both?
Btw, the model Id generator is what generates $modelId keys, so it is totally unrelated to the warning you get.
Also, I just added showDuplicateModelNameWarnings
to the global config in v0.48.2, which you can set to false to get rid of those warnings in testing envs (such as jest).
@xaviergonz I'll give that a whirl.
also:
fixed! legend.
I know it was mentioned (vaguely) here that avoiding the "Model already exists" warning in jest involves globalConfig, however being the absolute novice (at least compared to @xaviergonz) that I am, perhaps I am DoingItWrong(tm):
Everyone of our models that ends up involved in a test throws a warning that is some variation of this:
My jest setup:
If i throw a dirty console log in that
modelIdGenerator
, then I see a lot of expected spam in the console that the generated id is always 1 since none of our tests cases instantiate more than one instance of a model yet.If i remove the
jest.config.beforeeach-mobxkeystone.js
logic, then the model count logged in the console grows as expected, but the error/warning still remains.Any thoughts/help on properly utilising
setGlobalConfig
?