Skip to content

Commit

Permalink
test on tegg v3
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 committed Dec 29, 2024
1 parent 8ceb918 commit 67321cd
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 22 deletions.
16 changes: 11 additions & 5 deletions bin/test.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
#!/usr/bin/env bash

cd helloworld
rm -rf node_modules package-lock.json
npm install --registry=https://registry.npmmirror.com
npm run ci
cd helloworld
test() {
echo "Test $1"
cd $1
pwd
rm -rf node_modules package-lock.json
npm install --registry=https://registry.npmmirror.com
npm run ci
cd ..
}

test helloworld
test hello-tegg
1 change: 1 addition & 0 deletions hello-tegg/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ test/**/*.map
config/**/*.map
*.d.ts
*.tsbuildinfo
.egg/
2 changes: 1 addition & 1 deletion hello-tegg/app/middleware/trace_method.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import { EggContext, Next } from '@eggjs/tegg';

export async function traceMethod(ctx: EggContext, next: Next) {
await next();
ctx.body.data.message += ` (${ctx.method})`;
(ctx.body as any).data.message += ` (${ctx.method})`;
}
5 changes: 3 additions & 2 deletions hello-tegg/config/config.default.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { EggAppConfig, PowerPartial } from 'egg';
import { EggAppConfig } from 'egg';
// import { EggAppConfig, PowerPartial } from 'egg';

export default (appInfo: EggAppConfig) => {
const config = {} as PowerPartial<EggAppConfig>;
const config = {} as EggAppConfig;

// override config from framework / plugin
config.keys = appInfo.name + '123456';
Expand Down
5 changes: 3 additions & 2 deletions hello-tegg/config/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { EggPlugin } from 'egg';
// import { EggPlugin } from 'egg';

const plugin: EggPlugin = {
// const plugin: EggPlugin = {
const plugin = {
tegg: {
enable: true,
package: '@eggjs/tegg-plugin',
Expand Down
10 changes: 6 additions & 4 deletions hello-tegg/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
"stop": "egg-scripts stop",
"dev": "egg-bin dev",
"test-local": "egg-bin test",
"test": "npm run lint -- --fix && npm run test-local",
"cov": "egg-bin cov",
"pretest": "npm run clean && npm run lint -- --fix",
"test": "egg-bin test",
"tsc": "tsc -p tsconfig.json",
"ci": "npm run lint && npm run cov && npm run tsc",
"preci": "npm run lint",
"ci": "egg-bin cov",
"postci": "npm run tsc && npm run clean",
"lint": "eslint .",
"clean": "tsc -b --clean"
},
Expand All @@ -30,7 +32,7 @@
"devDependencies": {
"@types/mocha": "10",
"@types/node": "22",
"@egg/bin": "7",
"@eggjs/bin": "7",
"@eggjs/mock": "6",
"eslint": "8",
"eslint-config-egg": "14",
Expand Down
9 changes: 5 additions & 4 deletions hello-tegg/test/biz/HelloService.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Context } from 'egg';
import assert from 'assert';
import { app } from 'egg-mock/bootstrap';
import { strict as assert } from 'node:assert';
// import { EggContext } from 'egg';
import { app } from '@eggjs/mock/bootstrap';
import { HelloService } from '../../app/biz/HelloService';

describe('test/biz/HelloService.test.ts', () => {
let ctx: Context;
let ctx: any;
// let ctx: EggContext;
let helloService: HelloService;

beforeEach(async () => {
Expand Down
4 changes: 2 additions & 2 deletions hello-tegg/test/controller/HelloController.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { app } from 'egg-mock/bootstrap';
import assert from 'assert';
import { strict as assert } from 'node:assert';
import { app } from '@eggjs/mock/bootstrap';

describe('test/controller/HelloController.test.ts', () => {
it('should work', async () => {
Expand Down
13 changes: 11 additions & 2 deletions hello-tegg/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
{
"extends": "@eggjs/tsconfig",
"compilerOptions": {
"baseUrl": "./"
}
"baseUrl": ".",
"strict": true,
"noImplicitAny": true,
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"declaration": false
},
"exclude": [
"test"
]
}

0 comments on commit 67321cd

Please sign in to comment.