Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import * as chai from "chai";
- import * as td from "testdouble";
- import * as typeorm from "typeorm";
- const sinon = require("sinon");
- const sinonChai = require("sinon-chai");
- chai.use(sinonChai);
- declare global {
- namespace NodeJS {
- interface Global {
- td: any;
- chai: any;
- spy: any;
- sinon: any;
- }
- }
- }
- global.td = td;
- global.chai = chai;
- global.spy = sinon.spy;
- const sandbox = sinon.createSandbox();
- const connection = sinon.createStubInstance(typeorm.Connection, {
- findMetadata() {
- return {};
- },
- buildMetadatas() {
- return {};
- }
- });
- let manager;
- connection.transaction.callsFake(async fn => fn(manager)); // eslint-disable-line
- sinon.stub(typeorm, "getConnection").returns(connection);
- beforeEach(() => {
- manager = sandbox.createStubInstance(typeorm.EntityManager);
- });
- afterEach(() => sandbox.restore());
- console.log("bootstrap code here");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement