-
Notifications
You must be signed in to change notification settings - Fork 31
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
Error when running E2E tests with Nest.js #10
Comments
Hi, thanks for your issue. I think I need to investigate this more to handle this. Now you can also use something like that to prevent adding the data source several times: import { addTransactionalDataSource, getDataSourceByName } from 'typeorm-transactional';
// ...
TypeOrmModule.forRootAsync({
dataSourceFactory: async (options) => {
return getDataSourceByName('default') || addTransactionalDataSource(new DataSource(options));
},
}); or import { addTransactionalDataSource, deleteDataSourceByName } from 'typeorm-transactional';
// ...
TypeOrmModule.forRootAsync({
dataSourceFactory: async (options) => {
deleteDataSourceByName('default');
return addTransactionalDataSource(new DataSource(options));
},
}); |
If I use the Edit: My bad, I forgot that |
Thanks! Will notify you. |
Thank you. If I'm not mistaken if we add a name to options, if we use multiple data sources, all the data sources get the name as the default |
Hi there,
thanks for the package! It really is super useful.
My issue is that we can't run our E2E tests with it as of now. We get the console error
Error: DataSource with name "default" has already added.
all the time. I assume it has to do with the dataSourceFactory being called multiple times (in multiple TestingModules) for the same database. Any suggestion how to approach/debug this? The setup is more or less the same as the default testing setup that Nest.js suggests.The text was updated successfully, but these errors were encountered: