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

CI: Set up testing for all supported databases #207

Closed
michaelbromley opened this issue Nov 18, 2019 · 5 comments
Closed

CI: Set up testing for all supported databases #207

michaelbromley opened this issue Nov 18, 2019 · 5 comments

Comments

@michaelbromley
Copy link
Member

Currently in CI we run e2e tests against sql.js (SQLite). Generally, due to the use of the TypeORM layer, this means that things should work fine in the other supported database, namely mysql & postgres.

However, there is some DB-specific code (e.g. in the DefaultSearchPlugin) which has caused a couple of issues by being untested (e.g. #206).

It would be better to run all e2e tests against each database. This would require some re-working on the @vendure/testing package to allow other DBs to be used.

@michaelbromley michaelbromley changed the title CI: Set up testing for supported databases CI: Set up testing for all supported databases Nov 18, 2019
@rrubio
Copy link

rrubio commented Nov 18, 2019

@michaelbromley thank you, really appreciate it. In the meantime, is there anything i can do on my side to get rid of this error? #206

@michaelbromley
Copy link
Member Author

@rrubio I'll release a patch (v0.6.1) today that includes the fix for that.

@rrubio
Copy link

rrubio commented Nov 18, 2019

@michaelbromley you rock! thank you man!

@michaelbromley
Copy link
Member Author

https://github.com/vendure-ecommerce/vendure/blob/master/CHANGELOG.md#061-2019-11-18

Boom! Whaddya call that for service?!? 😇😆

@rrubio
Copy link

rrubio commented Nov 18, 2019

AWESOME!!!! thank you so much!

michaelbromley added a commit that referenced this issue Jan 28, 2020
Relates to #207. This change decouples the TestServer from the underlying database, allowing custom TestDbInitializers to be created for other TypeORM-supported DBs.

BREAKING CHANGE: The `@vendure/testing` package now requires you to explicitly register initializers for the databases you with to test against. This change enables e2e tests to be run against any database supported by TypeORM. The `dataDir` option has been removed from the call to the `TestServer.init()` method, as it is specific to the SqljsInitializer:

before:
```TypeScript
import { createTestEnvironment, testConfig } from '@vendure/testing';

describe('my e2e test suite', () => {
    const { server, adminClient } = createTestEnvironment(testConfig);

    beforeAll(() => {
        await server.init({
            dataDir: path.join(__dirname, '__data__'),
            initialData,
            productsCsvPath: path.join(__dirname, 'fixtures/e2e-products-minimal.csv'),
            customerCount: 1,
        });
    });

    //...
});
```

after:
```TypeScript
import { createTestEnvironment, registerInitializer, SqljsInitializer, testConfig } from '@vendure/testing';

registerInitializer('sqljs', new SqljsInitializer(path.join(__dirname, '__data__')));

describe('my e2e test suite', () => {
    const { server, adminClient } = createTestEnvironment(testConfig);

    beforeAll(() => {
        await server.init({
            initialData,
            productsCsvPath: path.join(__dirname, 'fixtures/e2e-products-minimal.csv'),
            customerCount: 1,
        });
    });

    //...
});
```
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