How to use the @nestjs/testing.Test function in @nestjs/testing

To help you get started, weโ€™ve selected a few @nestjs/testing examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ahrnee / nestjs-bff / packages / pkg-backend / lib-e2e / auth / auth.e2e-spec.js View on Github external
beforeAll(() => __awaiter(this, void 0, void 0, function* () {
        logger.trace('---- Starting Auth e2e ----');
        yield test_object_literals_constants_1.setupTestDataJwtTokens(nestjs_bff_config_1.NestjsBffConfig);
        // console.log('Auth-testData', JSON.stringify(testData, null, 2));
        const module = yield testing_1.Test.createTestingModule({
            imports: [auth_e2e_module_1.AuthE2eModule],
        }).compile();
        app = module.createNestApplication();
        yield app.init();
        httpServer = app.getHttpServer();
    }), 5 * 60 * 1000);
    //
github ahrnee / nestjs-bff / packages / pkg-backend / lib-e2e / core / global-setup-auth.js View on Github external
exports.setupAuth = (globalConfig, nestJsBffConfig) => __awaiter(this, void 0, void 0, function* () {
    const logger = logging_shared_module_1.getLogger();
    //
    // Setup
    //
    const module = yield testing_1.Test.createTestingModule({
        imports: [auth_e2e_module_1.AuthE2eModule],
    }).compile();
    const app = module.createNestApplication();
    yield app.init();
    const authenticationRepo = yield app.get(authentication_repo_1.AuthenticationRepo);
    const organizationRepo = yield app.get(organization_repo_1.OrganizationRepo);
    const userRepo = yield app.get(user_repo_1.UserRepo);
    const accessPermissionsRepo = yield app.get(access_permissions_repo_1.AccessPermissionsRepo);
    //
    // Add Data
    //
    // OrgA
    yield organizationRepo.create(test_object_literals_constants_1.testData.orgA.orgEntity, { skipAuthorization: true });
    // OrgA Admin User
    yield userRepo.create(test_object_literals_constants_1.testData.orgA.users.adminUser.userEntity, { skipAuthorization: true });
    yield authenticationRepo.create(test_object_literals_constants_1.testData.orgA.users.adminUser.authenticationEntity, { skipAuthorization: true });

@nestjs/testing

Nest - modern, fast, powerful node.js web framework (@testing)

MIT
Latest version published 30 days ago

Package Health Score

91 / 100
Full package analysis

Similar packages