backup
This commit is contained in:
@@ -1,24 +1,49 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import * as request from 'supertest';
|
||||
import { AppModule } from './../src/app.module';
|
||||
import { GraphQLModule } from '@nestjs/graphql';
|
||||
import {
|
||||
ApolloServerTestClient,
|
||||
createTestClient,
|
||||
} from 'apollo-server-testing';
|
||||
import { gql } from 'apollo-server-express';
|
||||
|
||||
describe('AppController (e2e)', () => {
|
||||
describe('ArticleResolver (e2e)', () => {
|
||||
let app: INestApplication;
|
||||
let apolloClient: ApolloServerTestClient;
|
||||
|
||||
beforeEach(async () => {
|
||||
beforeAll(async () => {
|
||||
const moduleFixture: TestingModule = await Test.createTestingModule({
|
||||
imports: [AppModule],
|
||||
}).compile();
|
||||
|
||||
app = moduleFixture.createNestApplication();
|
||||
await app.init();
|
||||
const module: GraphQLModule = moduleFixture.get<GraphQLModule>(
|
||||
GraphQLModule,
|
||||
);
|
||||
// apolloServer is protected, we need to cast module to any to get it
|
||||
apolloClient = createTestClient((module as any).apolloServer);
|
||||
});
|
||||
it('QUERY hello', async () => {
|
||||
const res = await apolloClient.query({
|
||||
query: gql`
|
||||
query {
|
||||
hello {
|
||||
message
|
||||
}
|
||||
}
|
||||
`,
|
||||
variables: {},
|
||||
});
|
||||
expect(res.data).toEqual({
|
||||
hello: {
|
||||
message: 'Hello, World!',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('/ (GET)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.get('/')
|
||||
.expect(200)
|
||||
.expect('Hello World!');
|
||||
afterAll(async () => {
|
||||
await app?.close();
|
||||
});
|
||||
});
|
||||
|
33
test/article.e2e-spec.ts
Normal file
33
test/article.e2e-spec.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import * as request from 'supertest';
|
||||
import { AppModule } from '../src/app.module';
|
||||
import { GraphQLModule } from '@nestjs/graphql';
|
||||
import {
|
||||
ApolloServerTestClient,
|
||||
createTestClient,
|
||||
} from 'apollo-server-testing';
|
||||
import { gql } from 'apollo-server-express';
|
||||
|
||||
describe('AppController (e2e)', () => {
|
||||
let app: INestApplication;
|
||||
let apolloClient: ApolloServerTestClient;
|
||||
|
||||
beforeAll(async () => {
|
||||
const moduleFixture: TestingModule = await Test.createTestingModule({
|
||||
imports: [AppModule],
|
||||
}).compile();
|
||||
|
||||
app = moduleFixture.createNestApplication();
|
||||
await app.init();
|
||||
const module: GraphQLModule = moduleFixture.get<GraphQLModule>(
|
||||
GraphQLModule,
|
||||
);
|
||||
// apolloServer is protected, we need to cast module to any to get it
|
||||
apolloClient = createTestClient((module as any).apolloServer);
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await app?.close();
|
||||
});
|
||||
});
|
0
test/data/article.e2e-spec.ts
Normal file
0
test/data/article.e2e-spec.ts
Normal file
@@ -1,8 +0,0 @@
|
||||
for (let i = 1; i <= 5; i++) {
|
||||
console.log(i * 10);
|
||||
}
|
||||
console.error('Error Message');
|
||||
console.error('Error Message 2');
|
||||
console.log('Bye-bye');
|
||||
|
||||
process.exit(1);
|
@@ -1,115 +0,0 @@
|
||||
{
|
||||
"secret": "boardcat",
|
||||
"ref": "refs/heads/master",
|
||||
"before": "429de1eaedf1da83f1e0e3ac3d8b20e771b7051c",
|
||||
"after": "429de1eaedf1da83f1e0e3ac3d8b20e771b7051c",
|
||||
"compare_url": "",
|
||||
"commits": [
|
||||
{
|
||||
"id": "429de1eaedf1da83f1e0e3ac3d8b20e771b7051c",
|
||||
"message": "test(pipeline-tasks): pass test cases.\n",
|
||||
"url": "https://git.ivanli.cc/Fennec/fennec-be/commit/429de1eaedf1da83f1e0e3ac3d8b20e771b7051c",
|
||||
"author": {
|
||||
"name": "Ivan",
|
||||
"email": "ivanli@live.cn",
|
||||
"username": ""
|
||||
},
|
||||
"committer": {
|
||||
"name": "Ivan",
|
||||
"email": "ivanli@live.cn",
|
||||
"username": ""
|
||||
},
|
||||
"verification": null,
|
||||
"timestamp": "0001-01-01T00:00:00Z",
|
||||
"added": null,
|
||||
"removed": null,
|
||||
"modified": null
|
||||
}
|
||||
],
|
||||
"head_commit": null,
|
||||
"repository": {
|
||||
"id": 3,
|
||||
"owner": {
|
||||
"id": 3,
|
||||
"login": "Fennec",
|
||||
"full_name": "",
|
||||
"email": "",
|
||||
"avatar_url": "https://git.ivanli.cc/user/avatar/Fennec/-1",
|
||||
"language": "",
|
||||
"is_admin": false,
|
||||
"last_login": "1970-01-01T08:00:00+08:00",
|
||||
"created": "2021-01-30T16:46:11+08:00",
|
||||
"username": "Fennec"
|
||||
},
|
||||
"name": "fennec-be",
|
||||
"full_name": "Fennec/fennec-be",
|
||||
"description": "Fennec CI/CD Back-End",
|
||||
"empty": false,
|
||||
"private": false,
|
||||
"fork": false,
|
||||
"template": false,
|
||||
"parent": null,
|
||||
"mirror": false,
|
||||
"size": 1897,
|
||||
"html_url": "https://git.ivanli.cc/Fennec/fennec-be",
|
||||
"ssh_url": "ssh://gitea@git.ivanli.cc:7018/Fennec/fennec-be.git",
|
||||
"clone_url": "https://git.ivanli.cc/Fennec/fennec-be.git",
|
||||
"original_url": "",
|
||||
"website": "",
|
||||
"stars_count": 1,
|
||||
"forks_count": 0,
|
||||
"watchers_count": 1,
|
||||
"open_issues_count": 0,
|
||||
"open_pr_counter": 0,
|
||||
"release_counter": 0,
|
||||
"default_branch": "master",
|
||||
"archived": false,
|
||||
"created_at": "2021-01-31T09:58:38+08:00",
|
||||
"updated_at": "2021-03-27T15:57:00+08:00",
|
||||
"permissions": {
|
||||
"admin": false,
|
||||
"push": false,
|
||||
"pull": false
|
||||
},
|
||||
"has_issues": true,
|
||||
"internal_tracker": {
|
||||
"enable_time_tracker": true,
|
||||
"allow_only_contributors_to_track_time": true,
|
||||
"enable_issue_dependencies": true
|
||||
},
|
||||
"has_wiki": true,
|
||||
"has_pull_requests": true,
|
||||
"has_projects": true,
|
||||
"ignore_whitespace_conflicts": false,
|
||||
"allow_merge_commits": true,
|
||||
"allow_rebase": true,
|
||||
"allow_rebase_explicit": true,
|
||||
"allow_squash_merge": true,
|
||||
"avatar_url": "",
|
||||
"internal": false
|
||||
},
|
||||
"pusher": {
|
||||
"id": 1,
|
||||
"login": "Ivan",
|
||||
"full_name": "Ivan Li",
|
||||
"email": "ivan@noreply.%(DOMAIN)s",
|
||||
"avatar_url": "https://git.ivanli.cc/user/avatar/Ivan/-1",
|
||||
"language": "zh-CN",
|
||||
"is_admin": true,
|
||||
"last_login": "2021-03-26T22:28:05+08:00",
|
||||
"created": "2021-01-23T18:15:30+08:00",
|
||||
"username": "Ivan"
|
||||
},
|
||||
"sender": {
|
||||
"id": 1,
|
||||
"login": "Ivan",
|
||||
"full_name": "Ivan Li",
|
||||
"email": "ivan@noreply.%(DOMAIN)s",
|
||||
"avatar_url": "https://git.ivanli.cc/user/avatar/Ivan/-1",
|
||||
"language": "zh-CN",
|
||||
"is_admin": true,
|
||||
"last_login": "2021-03-26T22:28:05+08:00",
|
||||
"created": "2021-01-23T18:15:30+08:00",
|
||||
"username": "Ivan"
|
||||
}
|
||||
}
|
@@ -1,7 +0,0 @@
|
||||
let timer;
|
||||
let count = 0;
|
||||
setTimeout(() => clearInterval(timer), 1_000);
|
||||
|
||||
timer = setInterval(() => {
|
||||
console.log(++count * 10);
|
||||
}, 95);
|
15
test/graphql-e2e.ts
Normal file
15
test/graphql-e2e.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const transformer = require('@nestjs/graphql/plugin');
|
||||
|
||||
module.exports.name = 'nestjs-graphql-transformer';
|
||||
// you should change the version number anytime you change the configuration below - otherwise, jest will not detect changes
|
||||
module.exports.version = 1;
|
||||
|
||||
module.exports.factory = (cs) => {
|
||||
return transformer.before(
|
||||
{
|
||||
// @nestjs/graphql/plugin options (can be empty)
|
||||
},
|
||||
cs.tsCompiler.program,
|
||||
);
|
||||
};
|
@@ -5,5 +5,12 @@
|
||||
"testRegex": ".e2e-spec.ts$",
|
||||
"transform": {
|
||||
"^.+\\.(t|j)s$": "ts-jest"
|
||||
},
|
||||
"globals": {
|
||||
"ts-jest": {
|
||||
"astTransformers": {
|
||||
"before": ["<rootDir>/graphql-e2e.ts"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user