From 4539bb9f394e84ed5c34191a19b9f7d824749131 Mon Sep 17 00:00:00 2001 From: xdan Date: Thu, 11 May 2023 02:05:22 +0300 Subject: [PATCH] Fix run tests --- Makefile | 6 +++--- {test => tools}/karma.conf.ts | 15 +++++++++++---- tools/tsconfig.json | 9 +++------ 3 files changed, 17 insertions(+), 13 deletions(-) rename {test => tools}/karma.conf.ts (89%) diff --git a/Makefile b/Makefile index 980b2baf0..573c62731 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) cwd := $(dir $(mkfile_path)) -build ?= build +build ?= es2015 devMode ?= development generateTypes ?= generateTypes es ?= es2015 @@ -19,7 +19,7 @@ WEBPACK_DEV_PORT := 2000 NODE_MODULES_BIN := ./node_modules/.bin TS_NODE_BASE := $(NODE_MODULES_BIN)/ts-node --project $(cwd)tools/tsconfig.json WEBPACK := $(TS_NODE_BASE) $(NODE_MODULES_BIN)/webpack -KARMA := $(TS_NODE_BASE) $(NODE_MODULES_BIN)/karma start +KARMA := @TS_NODE_TRANSPILE_ONLY=true $(TS_NODE_BASE) $(NODE_MODULES_BIN)/karma start .PHONY: version version: @@ -142,7 +142,7 @@ test-find: .PHONY: test-only-run test-only-run: - $(KARMA) --browsers $(browsers) ./test/karma.conf.ts --single-run $(singleRun) --build=$(build) --min=$(uglify) + $(KARMA) --browsers $(browsers) $(cwd)tools/karma.conf.ts --single-run $(singleRun) --build=$(build) --min=$(uglify) --cwd=$(cwd) .PHONY: coverage coverage: diff --git a/test/karma.conf.ts b/tools/karma.conf.ts similarity index 89% rename from test/karma.conf.ts rename to tools/karma.conf.ts index 0c40c9c26..d64f0c096 100644 --- a/test/karma.conf.ts +++ b/tools/karma.conf.ts @@ -7,12 +7,18 @@ import type { Config } from 'karma'; import * as yargs from 'yargs'; import * as fs from 'fs'; +import path from 'path'; const argv = yargs .option('grep', { type: 'string', description: 'Grep test glob pattern' }) + .option('cwd', { + type: 'string', + demandOption: true, + description: 'Work directory' + }) .option('build', { type: 'string', demandOption: true, @@ -31,12 +37,13 @@ if (argv.grep) { const buildDir = './build/' + argv.build; +const workDirectory = path.resolve(argv.cwd, buildDir); + if ( - !argv.build || - !fs.existsSync(buildDir) || - !fs.statSync(buildDir).isDirectory() + !fs.existsSync(workDirectory) || + !fs.statSync(workDirectory).isDirectory() ) { - throw new Error('Invalid build directory'); + throw new Error('Invalid build directory:' + workDirectory); } if (!fs.existsSync(buildDir + '/jodit' + (argv.min ? '.min' : '') + '.js')) { diff --git a/tools/tsconfig.json b/tools/tsconfig.json index 35bacc316..b696eb816 100644 --- a/tools/tsconfig.json +++ b/tools/tsconfig.json @@ -1,9 +1,6 @@ { - "extends": "ts-node/node16/tsconfig.json", + "extends": "ts-node/node16/tsconfig.json", "compilerOptions": { - "allowJs": true, - "resolveJsonModule": true, - "verbatimModuleSyntax": false, - "allowSyntheticDefaultImports": true - } + "target": "es5" + } }