From f4ed7d7b110484f9a04c68b3c3cd17f3e6afc9af Mon Sep 17 00:00:00 2001 From: James Sumners Date: Mon, 15 Apr 2024 09:30:15 -0400 Subject: [PATCH] chore: Updated versioned tests to use quiet output mode --- bin/run-versioned-tests.sh | 14 ++-- package-lock.json | 8 +- package.json | 2 +- test/versioned/nestjs/test-app/.eslintrc.js | 25 +++++++ test/versioned/nestjs/test-app/.prettierrc | 4 + test/versioned/nestjs/test-app/README.md | 73 +++++++++++++++++++ test/versioned/nestjs/test-app/nest-cli.json | 8 ++ test/versioned/nestjs/test-app/package.json | 69 ++++++++++++++++++ .../test-app/src/app.controller.spec.ts | 22 ++++++ .../nestjs/test-app/src/app.controller.ts | 12 +++ .../nestjs/test-app/src/app.module.ts | 10 +++ .../nestjs/test-app/src/app.service.ts | 8 ++ test/versioned/nestjs/test-app/src/main.ts | 8 ++ .../nestjs/test-app/test/app.e2e-spec.ts | 24 ++++++ .../nestjs/test-app/test/jest-e2e.json | 9 +++ .../nestjs/test-app/tsconfig.build.json | 4 + test/versioned/nestjs/test-app/tsconfig.json | 21 ++++++ 17 files changed, 311 insertions(+), 10 deletions(-) create mode 100644 test/versioned/nestjs/test-app/.eslintrc.js create mode 100644 test/versioned/nestjs/test-app/.prettierrc create mode 100644 test/versioned/nestjs/test-app/README.md create mode 100644 test/versioned/nestjs/test-app/nest-cli.json create mode 100644 test/versioned/nestjs/test-app/package.json create mode 100644 test/versioned/nestjs/test-app/src/app.controller.spec.ts create mode 100644 test/versioned/nestjs/test-app/src/app.controller.ts create mode 100644 test/versioned/nestjs/test-app/src/app.module.ts create mode 100644 test/versioned/nestjs/test-app/src/app.service.ts create mode 100644 test/versioned/nestjs/test-app/src/main.ts create mode 100644 test/versioned/nestjs/test-app/test/app.e2e-spec.ts create mode 100644 test/versioned/nestjs/test-app/test/jest-e2e.json create mode 100644 test/versioned/nestjs/test-app/tsconfig.build.json create mode 100644 test/versioned/nestjs/test-app/tsconfig.json diff --git a/bin/run-versioned-tests.sh b/bin/run-versioned-tests.sh index ba8cedefe2..60def5a507 100755 --- a/bin/run-versioned-tests.sh +++ b/bin/run-versioned-tests.sh @@ -15,11 +15,15 @@ SKIP_C8="${SKIP_C8:-false}" # HTML reports too C8_REPORTER="${C8_REPORTER:-lcov}" # Options: none, only, include -# None skips running external +# None skips running external # Only runs only external -# Inclue runs external with "internal" +# Include runs external with "internal" EXTERNAL_MODE="${EXTERNAL_MODE:-include}" +# OUTPUT_MODE maps to `--print` of the versioned-tests runner. +# Known values are "simple", "pretty", and "quiet". +OUTPUT_MODE="${OUTPUT_MODE:-quiet}" + # Determine context manager for sanity sake if [[ $NEW_RELIC_FEATURE_FLAG_LEGACY_CONTEXT_MANAGER == 1 ]]; then @@ -40,7 +44,7 @@ then "test/versioned-external/TEMP_TESTS/${1}/tests/versioned" ) elif [[ "$EXTERNAL_MODE" = "none" ]]; - then + then directories=( "test/versioned/${1}" ) @@ -59,7 +63,7 @@ else "test/versioned-external" ) elif [[ "$EXTERNAL_MODE" = "none" ]]; - then + then directories=( "test/versioned/" ) @@ -96,4 +100,4 @@ then fi export NR_LOADER=./esm-loader.mjs -time $C8 ./node_modules/.bin/versioned-tests $VERSIONED_MODE -i 2 --all --strict --samples $SAMPLES $JOBS_ARGS ${directories[@]} +time $C8 ./node_modules/.bin/versioned-tests $VERSIONED_MODE --print $OUTPUT_MODE -i 2 --all --strict --samples $SAMPLES $JOBS_ARGS ${directories[@]} diff --git a/package-lock.json b/package-lock.json index a09e886836..d3a26f77aa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -33,7 +33,7 @@ "devDependencies": { "@newrelic/eslint-config": "^0.3.0", "@newrelic/newrelic-oss-cli": "^0.1.2", - "@newrelic/test-utilities": "^8.4.0", + "@newrelic/test-utilities": "^8.5.0", "@octokit/rest": "^18.0.15", "@slack/bolt": "^3.7.0", "ajv": "^6.12.6", @@ -997,9 +997,9 @@ } }, "node_modules/@newrelic/test-utilities": { - "version": "8.4.0", - "resolved": "https://registry.npmjs.org/@newrelic/test-utilities/-/test-utilities-8.4.0.tgz", - "integrity": "sha512-WCr/zGAwZs2B1mI/Kf0aR+XofM61Vb0pPjCyS7adyLFBd82Ccb0kPRGiycc07ITQKvtmd6LdQnl3a2K+qaKA5g==", + "version": "8.5.0", + "resolved": "https://registry.npmjs.org/@newrelic/test-utilities/-/test-utilities-8.5.0.tgz", + "integrity": "sha512-lrdcoJiolBRhhuT7cd0YUN23zsF2WX0kUfmfA8+IGU+9T0witbkLC4AUnaaM9/OQx5qyZveaw5TFQl3XUSHTBg==", "dev": true, "dependencies": { "@smithy/eventstream-codec": "^2.1.1", diff --git a/package.json b/package.json index 776b07b793..879fe74901 100644 --- a/package.json +++ b/package.json @@ -217,7 +217,7 @@ "devDependencies": { "@newrelic/eslint-config": "^0.3.0", "@newrelic/newrelic-oss-cli": "^0.1.2", - "@newrelic/test-utilities": "^8.4.0", + "@newrelic/test-utilities": "^8.5.0", "@octokit/rest": "^18.0.15", "@slack/bolt": "^3.7.0", "ajv": "^6.12.6", diff --git a/test/versioned/nestjs/test-app/.eslintrc.js b/test/versioned/nestjs/test-app/.eslintrc.js new file mode 100644 index 0000000000..259de13c73 --- /dev/null +++ b/test/versioned/nestjs/test-app/.eslintrc.js @@ -0,0 +1,25 @@ +module.exports = { + parser: '@typescript-eslint/parser', + parserOptions: { + project: 'tsconfig.json', + tsconfigRootDir: __dirname, + sourceType: 'module', + }, + plugins: ['@typescript-eslint/eslint-plugin'], + extends: [ + 'plugin:@typescript-eslint/recommended', + 'plugin:prettier/recommended', + ], + root: true, + env: { + node: true, + jest: true, + }, + ignorePatterns: ['.eslintrc.js'], + rules: { + '@typescript-eslint/interface-name-prefix': 'off', + '@typescript-eslint/explicit-function-return-type': 'off', + '@typescript-eslint/explicit-module-boundary-types': 'off', + '@typescript-eslint/no-explicit-any': 'off', + }, +}; diff --git a/test/versioned/nestjs/test-app/.prettierrc b/test/versioned/nestjs/test-app/.prettierrc new file mode 100644 index 0000000000..dcb72794f5 --- /dev/null +++ b/test/versioned/nestjs/test-app/.prettierrc @@ -0,0 +1,4 @@ +{ + "singleQuote": true, + "trailingComma": "all" +} \ No newline at end of file diff --git a/test/versioned/nestjs/test-app/README.md b/test/versioned/nestjs/test-app/README.md new file mode 100644 index 0000000000..00a13b112a --- /dev/null +++ b/test/versioned/nestjs/test-app/README.md @@ -0,0 +1,73 @@ +

+ Nest Logo +

+ +[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456 +[circleci-url]: https://circleci.com/gh/nestjs/nest + +

A progressive Node.js framework for building efficient and scalable server-side applications.

+

+NPM Version +Package License +NPM Downloads +CircleCI +Coverage +Discord +Backers on Open Collective +Sponsors on Open Collective + + Support us + +

+ + +## Description + +[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository. + +## Installation + +```bash +$ npm install +``` + +## Running the app + +```bash +# development +$ npm run start + +# watch mode +$ npm run start:dev + +# production mode +$ npm run start:prod +``` + +## Test + +```bash +# unit tests +$ npm run test + +# e2e tests +$ npm run test:e2e + +# test coverage +$ npm run test:cov +``` + +## Support + +Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support). + +## Stay in touch + +- Author - [Kamil Myƛliwiec](https://kamilmysliwiec.com) +- Website - [https://nestjs.com](https://nestjs.com/) +- Twitter - [@nestframework](https://twitter.com/nestframework) + +## License + +Nest is [MIT licensed](LICENSE). diff --git a/test/versioned/nestjs/test-app/nest-cli.json b/test/versioned/nestjs/test-app/nest-cli.json new file mode 100644 index 0000000000..f9aa683b1a --- /dev/null +++ b/test/versioned/nestjs/test-app/nest-cli.json @@ -0,0 +1,8 @@ +{ + "$schema": "https://json.schemastore.org/nest-cli", + "collection": "@nestjs/schematics", + "sourceRoot": "src", + "compilerOptions": { + "deleteOutDir": true + } +} diff --git a/test/versioned/nestjs/test-app/package.json b/test/versioned/nestjs/test-app/package.json new file mode 100644 index 0000000000..fe98fd4d9b --- /dev/null +++ b/test/versioned/nestjs/test-app/package.json @@ -0,0 +1,69 @@ +{ + "name": "test-app", + "version": "0.0.1", + "description": "", + "author": "", + "private": true, + "license": "UNLICENSED", + "scripts": { + "build": "nest build", + "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", + "start": "nest start", + "start:dev": "nest start --watch", + "start:debug": "nest start --debug --watch", + "start:prod": "node dist/main", + "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", + "test": "jest", + "test:watch": "jest --watch", + "test:cov": "jest --coverage", + "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", + "test:e2e": "jest --config ./test/jest-e2e.json" + }, + "dependencies": { + "@nestjs/common": "^10.0.0", + "@nestjs/core": "^10.0.0", + "@nestjs/platform-express": "^10.0.0", + "reflect-metadata": "^0.2.0", + "rxjs": "^7.8.1" + }, + "devDependencies": { + "@nestjs/cli": "^10.0.0", + "@nestjs/schematics": "^10.0.0", + "@nestjs/testing": "^10.0.0", + "@types/express": "^4.17.17", + "@types/jest": "^29.5.2", + "@types/node": "^20.3.1", + "@types/supertest": "^6.0.0", + "@typescript-eslint/eslint-plugin": "^6.0.0", + "@typescript-eslint/parser": "^6.0.0", + "eslint": "^8.42.0", + "eslint-config-prettier": "^9.0.0", + "eslint-plugin-prettier": "^5.0.0", + "jest": "^29.5.0", + "prettier": "^3.0.0", + "source-map-support": "^0.5.21", + "supertest": "^6.3.3", + "ts-jest": "^29.1.0", + "ts-loader": "^9.4.3", + "ts-node": "^10.9.1", + "tsconfig-paths": "^4.2.0", + "typescript": "^5.1.3" + }, + "jest": { + "moduleFileExtensions": [ + "js", + "json", + "ts" + ], + "rootDir": "src", + "testRegex": ".*\\.spec\\.ts$", + "transform": { + "^.+\\.(t|j)s$": "ts-jest" + }, + "collectCoverageFrom": [ + "**/*.(t|j)s" + ], + "coverageDirectory": "../coverage", + "testEnvironment": "node" + } +} diff --git a/test/versioned/nestjs/test-app/src/app.controller.spec.ts b/test/versioned/nestjs/test-app/src/app.controller.spec.ts new file mode 100644 index 0000000000..d22f3890a3 --- /dev/null +++ b/test/versioned/nestjs/test-app/src/app.controller.spec.ts @@ -0,0 +1,22 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { AppController } from './app.controller'; +import { AppService } from './app.service'; + +describe('AppController', () => { + let appController: AppController; + + beforeEach(async () => { + const app: TestingModule = await Test.createTestingModule({ + controllers: [AppController], + providers: [AppService], + }).compile(); + + appController = app.get(AppController); + }); + + describe('root', () => { + it('should return "Hello World!"', () => { + expect(appController.getHello()).toBe('Hello World!'); + }); + }); +}); diff --git a/test/versioned/nestjs/test-app/src/app.controller.ts b/test/versioned/nestjs/test-app/src/app.controller.ts new file mode 100644 index 0000000000..cce879ee62 --- /dev/null +++ b/test/versioned/nestjs/test-app/src/app.controller.ts @@ -0,0 +1,12 @@ +import { Controller, Get } from '@nestjs/common'; +import { AppService } from './app.service'; + +@Controller() +export class AppController { + constructor(private readonly appService: AppService) {} + + @Get() + getHello(): string { + return this.appService.getHello(); + } +} diff --git a/test/versioned/nestjs/test-app/src/app.module.ts b/test/versioned/nestjs/test-app/src/app.module.ts new file mode 100644 index 0000000000..86628031ca --- /dev/null +++ b/test/versioned/nestjs/test-app/src/app.module.ts @@ -0,0 +1,10 @@ +import { Module } from '@nestjs/common'; +import { AppController } from './app.controller'; +import { AppService } from './app.service'; + +@Module({ + imports: [], + controllers: [AppController], + providers: [AppService], +}) +export class AppModule {} diff --git a/test/versioned/nestjs/test-app/src/app.service.ts b/test/versioned/nestjs/test-app/src/app.service.ts new file mode 100644 index 0000000000..927d7cca0b --- /dev/null +++ b/test/versioned/nestjs/test-app/src/app.service.ts @@ -0,0 +1,8 @@ +import { Injectable } from '@nestjs/common'; + +@Injectable() +export class AppService { + getHello(): string { + return 'Hello World!'; + } +} diff --git a/test/versioned/nestjs/test-app/src/main.ts b/test/versioned/nestjs/test-app/src/main.ts new file mode 100644 index 0000000000..13cad38cff --- /dev/null +++ b/test/versioned/nestjs/test-app/src/main.ts @@ -0,0 +1,8 @@ +import { NestFactory } from '@nestjs/core'; +import { AppModule } from './app.module'; + +async function bootstrap() { + const app = await NestFactory.create(AppModule); + await app.listen(3000); +} +bootstrap(); diff --git a/test/versioned/nestjs/test-app/test/app.e2e-spec.ts b/test/versioned/nestjs/test-app/test/app.e2e-spec.ts new file mode 100644 index 0000000000..50cda62332 --- /dev/null +++ b/test/versioned/nestjs/test-app/test/app.e2e-spec.ts @@ -0,0 +1,24 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { INestApplication } from '@nestjs/common'; +import * as request from 'supertest'; +import { AppModule } from './../src/app.module'; + +describe('AppController (e2e)', () => { + let app: INestApplication; + + beforeEach(async () => { + const moduleFixture: TestingModule = await Test.createTestingModule({ + imports: [AppModule], + }).compile(); + + app = moduleFixture.createNestApplication(); + await app.init(); + }); + + it('/ (GET)', () => { + return request(app.getHttpServer()) + .get('/') + .expect(200) + .expect('Hello World!'); + }); +}); diff --git a/test/versioned/nestjs/test-app/test/jest-e2e.json b/test/versioned/nestjs/test-app/test/jest-e2e.json new file mode 100644 index 0000000000..e9d912f3e3 --- /dev/null +++ b/test/versioned/nestjs/test-app/test/jest-e2e.json @@ -0,0 +1,9 @@ +{ + "moduleFileExtensions": ["js", "json", "ts"], + "rootDir": ".", + "testEnvironment": "node", + "testRegex": ".e2e-spec.ts$", + "transform": { + "^.+\\.(t|j)s$": "ts-jest" + } +} diff --git a/test/versioned/nestjs/test-app/tsconfig.build.json b/test/versioned/nestjs/test-app/tsconfig.build.json new file mode 100644 index 0000000000..64f86c6bd2 --- /dev/null +++ b/test/versioned/nestjs/test-app/tsconfig.build.json @@ -0,0 +1,4 @@ +{ + "extends": "./tsconfig.json", + "exclude": ["node_modules", "test", "dist", "**/*spec.ts"] +} diff --git a/test/versioned/nestjs/test-app/tsconfig.json b/test/versioned/nestjs/test-app/tsconfig.json new file mode 100644 index 0000000000..95f5641cf7 --- /dev/null +++ b/test/versioned/nestjs/test-app/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "module": "commonjs", + "declaration": true, + "removeComments": true, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "allowSyntheticDefaultImports": true, + "target": "ES2021", + "sourceMap": true, + "outDir": "./dist", + "baseUrl": "./", + "incremental": true, + "skipLibCheck": true, + "strictNullChecks": false, + "noImplicitAny": false, + "strictBindCallApply": false, + "forceConsistentCasingInFileNames": false, + "noFallthroughCasesInSwitch": false + } +}