viniciusjssouza / typeorm-transactional-tests Goto Github PK
View Code? Open in Web Editor NEWAdd transactional tests to typeorm projects
License: MIT License
Add transactional tests to typeorm projects
License: MIT License
Doesn't seem to be working:
# e2e.spec.ts
describe('e2e', () => {
let app: INestApplication;
beforeAll(async () => {
const moduleFixture = await Test.createTestingModule({
imports: [AppModule],
}).compile();
const appPreInit = moduleFixture.createNestApplication();
app = await appPreInit.init();
});
afterAll(async () => {
await app.close();
});
});
# transactional-context.ts
// eslint-disable-next-line import/no-extraneous-dependencies
import { TransactionalTestContext } from 'typeorm-transactional-tests';
import { getConnection } from 'typeorm';
let transactionalContext: TransactionalTestContext;
let connection;
// @ts-ignore
global.beforeEach(async () => {
connection = getConnection();
transactionalContext = new TransactionalTestContext(connection);
transactionalContext.start();
});
// @ts-ignore
global.afterEach(async () => {
console.log('cleaning up..');
transactionalContext.finish();
});
Output:
npm run test:e2e
> [email protected] test:e2e /Users/danklasson/Code/analyze/backend
> jest --config ./test/jest-e2e.json
console.log node_modules/typeorm/platform/PlatformTools.js:197
query: START TRANSACTION
console.log node_modules/typeorm/platform/PlatformTools.js:197
query: START TRANSACTION
console.log node_modules/typeorm/platform/PlatformTools.js:197
query: INSERT INTO `project`(`id`, `name`) VALUES (DEFAULT, ?) -- PARAMETERS: ["Ondricka, Stark and Breitenberg"]
console.log node_modules/typeorm/platform/PlatformTools.js:197
query: COMMIT
console.log node_modules/typeorm/platform/PlatformTools.js:197
query: SELECT `Project`.`id` AS `Project_id`, `Project`.`name` AS `Project_name` FROM `project` `Project`
console.log src/project/project.e2e-spec.ts:33
[ Project { id: 1, name: 'Ondricka, Stark and Breitenberg' } ]
PASS src/project/project.e2e-spec.ts
e2e
✓ should fetch projects (137ms)
✓ should fetch projects2 (31ms)
Test Suites: 1 passed, 1 total
Tests: 2 passed, 2 total
Snapshots: 0 total
Time: 4.581s, estimated 5s
Ran all test suites.
console.log test/test.transactional-context.ts:17
cleaning up..
console.log node_modules/typeorm/platform/PlatformTools.js:197
query: ROLLBACK
console.log node_modules/typeorm/platform/PlatformTools.js:197
query: START TRANSACTION
console.log node_modules/typeorm/platform/PlatformTools.js:197
query: START TRANSACTION
console.log node_modules/typeorm/platform/PlatformTools.js:197
query: INSERT INTO `project`(`id`, `name`) VALUES (DEFAULT, ?) -- PARAMETERS: ["Daugherty, Lesch and Schmidt"]
console.log node_modules/typeorm/platform/PlatformTools.js:197
query: COMMIT
console.log node_modules/typeorm/platform/PlatformTools.js:197
query: SELECT `Project`.`id` AS `Project_id`, `Project`.`name` AS `Project_name` FROM `project` `Project`
console.log src/project/project.e2e-spec.ts:53
[ Project { id: 1, name: 'Ondricka, Stark and Breitenberg' },
Project { id: 2, name: 'Daugherty, Lesch and Schmidt' } ]
console.log test/test.transactional-context.ts:17
cleaning up..
console.log node_modules/typeorm/platform/PlatformTools.js:197
query: ROLLBACK
beforeAll(async () => {
const connection = getConnection()
const transactionalContext = new TransactionalTestContext(connection)
await transactionalContext.start()
})
Argument of type 'import("~/node_modules/typeorm/connection/Connection").Connection' is not assignable to parameter of type 'import("~/node_modules/typeorm-transactional-tests/node_modules/typeorm/connection/Connection").Connection'.
Types of property 'options' are incompatible.
Type 'import("~/node_modules/typeorm/connection/ConnectionOptions").ConnectionOptions' is not assignable to type 'import("~/node_modules/typeorm-transactional-tests/node_modules/typeorm/connection/ConnectionOptions").ConnectionOptions'.
Type 'MysqlConnectionOptions' is not assignable to type 'ConnectionOptions'.
Type 'import("~/node_modules/typeorm/driver/mysql/MysqlConnectionOptions").MysqlConnectionOptions' is not assignable to type 'import("~/node_modules/typeorm-transactional-tests/node_modules/typeorm/driver/mysql/MysqlConnectionOptions").MysqlConnectionOptions'.
Types of property 'entities' are incompatible.
Type '(string | Function | import("~/node_modules/typeorm/entity-schema/EntitySchema").EntitySchema<any>)[] | undefined' is not assignable to type '(string | Function | import("~/node_modules/typeorm-transactional-tests/node_modules/typeorm/entity-schema/EntitySchema").EntitySchema<any>)[] | undefined'.
Type '(string | Function | import("~/node_modules/typeorm/entity-schema/EntitySchema").EntitySchema<any>)[]' is not assignable to type '(string | Function | import("~/node_modules/typeorm-transactional-tests/node_modules/typeorm/entity-schema/EntitySchema").EntitySchema<any>)[]'.
Type 'string | Function | import("~/node_modules/typeorm/entity-schema/EntitySchema").EntitySchema<any>' is not assignable to type 'string | Function | import("~/node_modules/typeorm-transactional-tests/node_modules/typeorm/entity-schema/EntitySchema").EntitySchema<any>'.
Type 'EntitySchema<any>' is not assignable to type 'string | Function | EntitySchema<any>'.
Type 'import("~/node_modules/typeorm/entity-schema/EntitySchema").EntitySchema<any>' is not assignable to type 'import("~/node_modules/typeorm-transactional-tests/node_modules/typeorm/entity-schema/EntitySchema").EntitySchema<any>'.
The types of 'options.type' are incompatible between these types.
Type '"regular" | "view" | "junction" | "closure" | "closure-junction" | "entity-child" | undefined' is not assignable to type '"regular" | "junction" | "closure" | "closure-junction" | "entity-child" | undefined'.
Type '"view"' is not assignable to type '"regular" | "junction" | "closure" | "closure-junction" | "entity-child" | undefined'.ts(2345)
Are there any plans to update this lib to typeorm 0.3?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.