From 8799a2dac2ce61b76b10fdfe245ea2f05c9947a8 Mon Sep 17 00:00:00 2001 From: Shigma <1700011071@pku.edu.cn> Date: Fri, 24 Jan 2020 22:57:27 +0800 Subject: [PATCH] feat(test-utils): BREAKING Session API Refactor --- build/jest.ts | 14 +++++++++----- jest.config.js | 3 +++ packages/test-utils/src/koishi.ts | 1 + packages/test-utils/src/session.ts | 25 +++++++++++-------------- 4 files changed, 24 insertions(+), 19 deletions(-) diff --git a/build/jest.ts b/build/jest.ts index 8c5edd4b96..afaa764142 100644 --- a/build/jest.ts +++ b/build/jest.ts @@ -4,13 +4,17 @@ import { resolve } from 'path' const args = ['jest', '--coverage'] -if (process.argv[2]) { - args.push(process.argv[2]) - if (process.argv[3]) { - args.push('--collectCoverageFrom', `**/${process.argv[3]}/**/*.ts`) +const [,, argv2, argv3] = process.argv + +if (argv2 && !argv2.startsWith('-')) { + args.push(argv2) + if (argv3 && !argv3.startsWith('-')) { + args.push('--collectCoverageFrom', `**/${argv3}/**/*.ts`, ...process.argv.slice(3)) + } else { + args.push(...process.argv.slice(3)) } } else { - args.push('packages/.+\\.spec\\.ts') + args.push('packages/.+\\.spec\\.ts', ...process.argv.slice(2)) } const child = spawn('npx', args, { stdio: 'inherit' }) diff --git a/jest.config.js b/jest.config.js index 30fb465b88..48d82e1206 100644 --- a/jest.config.js +++ b/jest.config.js @@ -12,7 +12,10 @@ module.exports = { moduleNameMapper: { "koishi-(test-utils|(database|plugin)-[\\w-]+)(/dist)?": "/packages/$1/src", "koishi-[\\w-]+": "/packages/$0/src", + "shiki-core": "/bots/shiki/core", + "touhou-words": "/bots/shiki/lib/touhou-words", "shiki-universe": "/bots/shiki/lib/shiki-universe/src", + "inference-puzzles": "/bots/shiki/lib/inference-puzzles/src", }, coverageReporters: ['text', 'lcov'], coveragePathIgnorePatterns: [ diff --git a/packages/test-utils/src/koishi.ts b/packages/test-utils/src/koishi.ts index 937e3f331a..05f2a668ac 100644 --- a/packages/test-utils/src/koishi.ts +++ b/packages/test-utils/src/koishi.ts @@ -20,6 +20,7 @@ interface MockedRandomMultiPick extends RealRandomMultiPick, jest.Mock