Skip to content

Commit

Permalink
chore: e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mrsimonemms committed Aug 28, 2023
1 parent bb93d53 commit 97a756c
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ jobs:
- test
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Required for goreleaser changelog to work correctly

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
Expand Down Expand Up @@ -116,19 +114,3 @@ jobs:
platforms: {{ '${{ steps.docker.outputs.platforms }}' }}
push: {{ '${{ github.ref == \'refs/heads/main\' }}' }}
tags: {{ '${{ steps.docker.outputs.image_name }},${{ steps.docker.outputs.container_tagged_image }}' }}

- name: Set up Go
if: steps.branch-name.outputs.is_tag == 'true'
uses: actions/setup-go@v3
with:
go-version: '>=1.20.0'

- name: Run GoReleaser
if: steps.branch-name.outputs.is_tag == 'true'
uses: goreleaser/goreleaser-action@v4
with:
version: latest
args: release --clean
env:
GIT_REPO: {{ '${{ steps.docker.outputs.gitRepo }}' }}
GITHUB_TOKEN: {{ '${{ secrets.GITHUB_TOKEN }}' }}
24 changes: 0 additions & 24 deletions js/{{ cookiecutter.project_name }}/nestjs/test/app.e2e-spec.ts

This file was deleted.

16 changes: 16 additions & 0 deletions js/{{ cookiecutter.project_name }}/nestjs/test/health.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import * as supertest from 'supertest';
import { request } from './setup';

describe('HealthController (e2e)', () => {
let app: supertest.Test;

describe('/', () => {
describe('GET', () => {
beforeEach(async () => {
app = (await request())().get('/health');
});

it('should return a healthy state', () => app.expect(200));
});
});
});
35 changes: 35 additions & 0 deletions js/{{ cookiecutter.project_name }}/nestjs/test/setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
process.env.LOG_LEVEL = 'silent';

import { INestApplication } from '@nestjs/common';
import { Test, TestingModule } from '@nestjs/testing';
import * as supertest from 'supertest';
import { AppModule } from '../src/app.module';

let app: INestApplication;

export const destroyApp = async () => {
if (app) {
await app.close();

/* Remove definition to prevent being run again */
app = undefined;
}
};

export const request = async (): Promise<
() => supertest.SuperTest<supertest.Test>
> => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [AppModule],
}).compile();

app = moduleFixture.createNestApplication();
await app.init();

return () => supertest(app.getHttpServer());
};

export { supertest };

// Ensure that the test app is correctly destroyed after use
afterEach(() => destroyApp());
4 changes: 2 additions & 2 deletions js/{{ cookiecutter.project_name }}/svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"eslint": "^8.28.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-svelte": "^2.30.0",
"prettier": "^2.8.0",
"prettier-plugin-svelte": "^2.10.1",
"prettier": "^3.0.0",
"prettier-plugin-svelte": "^3.0.0",
"svelte": "^4.0.5",
"svelte-check": "^3.4.3",
"tslib": "^2.4.1",
Expand Down
26 changes: 11 additions & 15 deletions js/{{ cookiecutter.project_name }}/svelte/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
{
"extends": "./.svelte-kit/tsconfig.json",
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true
}
// Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
//
// If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes
// from the referenced tsconfig.json - TypeScript does not merge them in
"extends": "./.svelte-kit/tsconfig.json",
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true
}
}

0 comments on commit 97a756c

Please sign in to comment.