You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This was originally posted as a question at the end of #677 Is there any way to modularize routes? But it has not gotten a response because that issue is closed. So opening this as a new issue.
I did the second way because I need to modularize all config elements, not just routes. And it does work fully in environment 'test' - server.config() does seem to be additive for all the elements I am using - models, factories, serializers and routes - so I can add them piece-by-piece. And then when I call my seed data function in each test, it correctly seeds data using the models, factories, etc., and everything works. My basic steps are:
Construct the server object (with just environment in the initial config) with createServer
Call all my add....(server) functions to add my config elements piece-by-piece (no seeds part in the config)
Call my seed...Data(server) function in each test to seed the data
But I have not been able to quite get it to work in environment 'development'. And it has to do with the fact that 'development' environment seems to require that the seed data function(s) be called through the seeds part of the config. Rather than after the server object is constructed.
So there ends up being a timing problem. The seeds part of the config seems to execute while the server object is being constructed, but at that time I have not yet added my config pieces such as models and factories, so the seed data comes out wrong.
So, I need to manually call my seed...Data(server) function after the server object is constructed, same as I do with 'test' environment, but that does not seem to be working. My seed data still comes out wrong, as if it still does not have visibility/access to the factories, even though by then they are there.
So, does anyone know a way to get this to work? With 'development' environment, to manually call seed...Data(server) function(s) after the server object is constructed and not use the seeds part of the config?
If there is not a way, could a fix be provided so that it could work this way? It seems like a sound concept - to be able to manually seed data after the server object is constructed, with any environment including 'development'.
And I am trying to call it for 'development' like:
if (process.env.NODE_ENV === 'development') {
const server = startMocksServer({ environment: 'development' });
seedMockData(server);
}
Instead of the usual:
if (process.env.NODE_ENV === 'development') {
startMocksServer({ environment: 'development' });
}
And, if I simply change environment: from 'development' to 'test', it does work, I just lose the console logging in the browser, and my response delays are shorter.
So, it seems tantalizingly close and as if it should work. Can you investigate and see if this could be made to work? (Seeding the data after-the-fact with any environment including 'development'.)
I am using version 0.1.46, which is the latest at the time of writing this.
This was originally posted as a question at the end of #677 Is there any way to modularize routes? But it has not gotten a response because that issue is closed. So opening this as a new issue.
I did the second way because I need to modularize all config elements, not just routes. And it does work fully in environment 'test' - server.config() does seem to be additive for all the elements I am using - models, factories, serializers and routes - so I can add them piece-by-piece. And then when I call my seed data function in each test, it correctly seeds data using the models, factories, etc., and everything works. My basic steps are:
But I have not been able to quite get it to work in environment 'development'. And it has to do with the fact that 'development' environment seems to require that the seed data function(s) be called through the seeds part of the config. Rather than after the server object is constructed.
So there ends up being a timing problem. The seeds part of the config seems to execute while the server object is being constructed, but at that time I have not yet added my config pieces such as models and factories, so the seed data comes out wrong.
So, I need to manually call my seed...Data(server) function after the server object is constructed, same as I do with 'test' environment, but that does not seem to be working. My seed data still comes out wrong, as if it still does not have visibility/access to the factories, even though by then they are there.
So, does anyone know a way to get this to work? With 'development' environment, to manually call seed...Data(server) function(s) after the server object is constructed and not use the seeds part of the config?
If there is not a way, could a fix be provided so that it could work this way? It seems like a sound concept - to be able to manually seed data after the server object is constructed, with any environment including 'development'.
So, my start server function is like:
And I am trying to call it for 'development' like:
Instead of the usual:
And, if I simply change environment: from 'development' to 'test', it does work, I just lose the console logging in the browser, and my response delays are shorter.
So, it seems tantalizingly close and as if it should work. Can you investigate and see if this could be made to work? (Seeding the data after-the-fact with any environment including 'development'.)
I am using version 0.1.46, which is the latest at the time of writing this.
Originally posted by @scottconso in #677 (comment)
The text was updated successfully, but these errors were encountered: