Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve test process #1977

Merged
merged 4 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions demo/scripts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
"roosterjs-color-utils": ["packages/roosterjs-color-utils/lib/index"],
"roosterjs-color-utils/lib/*": ["packages/roosterjs-color-utils/lib/*"],
"roosterjs-content-model-types": [
"packages-content-model/roosterjs-content-model-dom/lib/index"
"packages-content-model/roosterjs-content-model-types/lib/index"
],
"roosterjs-content-model-types/lib/*": [
"packages-content-model/roosterjs-content-model-dom/lib/*"
"packages-content-model/roosterjs-content-model-types/lib/*"
],
"roosterjs-content-model-dom": [
"packages-content-model/roosterjs-content-model-dom/lib/index"
Expand All @@ -38,10 +38,10 @@
"packages-content-model/roosterjs-content-model-dom/lib/*"
],
"roosterjs-content-model-editor": [
"packages-content-model/roosterjs-content-model-dom/lib/index"
"packages-content-model/roosterjs-content-model-editor/lib/index"
],
"roosterjs-content-model-editor/lib/*": [
"packages-content-model/roosterjs-content-model-dom/lib/*"
"packages-content-model/roosterjs-content-model-editor/lib/*"
],
"roosterjs-react": ["packages-ui/roosterjs-react/lib/index"],
"roosterjs-react/lib/*": ["packages-ui/roosterjs-react/lib/*"]
Expand Down
31 changes: 19 additions & 12 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,22 @@ module.exports = function (config) {
launcher.push('Firefox');
}

const tsConfig = {
compilerOptions: {
rootDir: rootPath,
declaration: false,
strict: false,
paths: {
'*': [
'*',
rootPath + '/packages/*',
rootPath + '/packages-ui/*',
rootPath + '/packages-content-model/*',
],
},
},
};

const rules = runCoverage
? [
{
Expand All @@ -57,30 +73,21 @@ module.exports = function (config) {
{ loader: '@jsdevtools/coverage-istanbul-loader' },
{
loader: 'ts-loader',
options: {
compilerOptions: {
rootDir: rootPath,
declaration: false,
},
},
options: tsConfig,
},
],
},
{
test: /test(\\|\/).*\.ts$/,
loader: 'ts-loader',
options: {
compilerOptions: { rootDir: rootPath, strict: false, declaration: false },
},
options: tsConfig,
},
]
: [
{
test: /\.ts$/,
loader: 'ts-loader',
options: {
compilerOptions: { rootDir: rootPath, strict: false, declaration: false },
},
options: tsConfig,
},
];

Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"builddemo": "node tools/build.js builddemo",
"builddoc": "node tools/build.js builddoc",
"build": "node tools/build.js clean checkdep normalize tslint buildcommonjs dts packprod builddemo",
"build:ci": "node --max-old-space-size=8192 tools/build.js --noProgressBar clean checkdep normalize tslint buildcommonjs buildamd buildmjs dts pack packprod builddemo builddoc",
"buildtest": "node tools/build.js normalize buildtest",
"build:ci": "node --max-old-space-size=8192 tools/build.js --noProgressBar clean checkdep normalize tslint buildcommonjs buildamd buildmjs buildtest dts pack packprod builddemo builddoc",
"start": "node tools/start.js",
"test": "node tools/build.js normalize & karma start --chrome",
"test:chrome": "node tools/build.js normalize & karma start --chrome",
Expand Down Expand Up @@ -63,7 +64,7 @@
"sass": "^1.49.8",
"sass-loader": "8.0.2",
"toposort": "2.0.2",
"ts-loader": "7.0.2",
"ts-loader": "9.4.4",
"tslib": "^2.3.1",
"tslint": "6.1.2",
"tslint-eslint-rules": "5.4.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const GOOGLE_SHEET_NODE_NAME = 'google-sheets-html-origin';
* 4. Content copied from Power Point
* (This class is still under development, and may still be changed in the future with some breaking changes)
*/
export default class ContentModelFormatPlugin implements EditorPlugin {
export default class ContentModelPastePlugin implements EditorPlugin {
private editor: IContentModelEditor | null = null;

/**
Expand Down
24 changes: 24 additions & 0 deletions packages-content-model/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"strict": false,
"target": "es5",
"module": "commonjs",
"noEmit": true,
"sourceMap": true,
"inlineSources": true,
"declaration": true,
"removeComments": false,
"noImplicitAny": true,
"preserveConstEnums": true,
"noUnusedLocals": true,
"downlevelIteration": true,
"importHelpers": true,
"baseUrl": ".",
"paths": {
"*": ["*", "../packages/*"]
},
"rootDir": "..",
"lib": ["es6", "dom"]
},
"include": ["./*/test/**/*.ts"]
}
2 changes: 2 additions & 0 deletions packages-ui/roosterjs-react/test/emptyTest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Add this empty test file for now to pass the build
describe('roosterjs-react', () => {});
2 changes: 1 addition & 1 deletion packages-ui/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
"rootDir": ".",
"lib": ["es6", "dom"]
},
"include": ["**/*.ts", "**/*.tsx"]
"include": ["./*/lib/**/*.ts", "./*/lib/**/*.tsx"]
}
23 changes: 23 additions & 0 deletions packages-ui/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"strict": false,
"jsx": "react",
"target": "es5",
"module": "commonjs",
"noEmit": true,
"sourceMap": true,
"inlineSources": true,
"declaration": true,
"removeComments": false,
"noImplicitAny": true,
"preserveConstEnums": true,
"noUnusedLocals": true,
"baseUrl": ".",
"paths": {
"*": ["*", "../packages/*"]
},
"rootDir": "..",
"lib": ["es6", "dom"]
},
"include": ["./*/test/**/*.ts", "./*/test/**/*.tsx"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export interface PluginKeyDownEventData {
/**
* Whether this event is handled by edit feature
*/
handledByEditFeature: boolean;
handledByEditFeature?: boolean;
}

/**
Expand Down
24 changes: 24 additions & 0 deletions packages/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"strict": false,
"target": "es5",
"module": "commonjs",
"noEmit": true,
"sourceMap": true,
"inlineSources": true,
"declaration": true,
"removeComments": false,
"noImplicitAny": true,
"preserveConstEnums": true,
"noUnusedLocals": true,
"downlevelIteration": true,
"importHelpers": true,
"baseUrl": ".",
"paths": {
"*": ["*"]
},
"rootDir": "..",
"lib": ["es6", "dom"]
},
"include": ["./*/test/**/*.ts"]
}
3 changes: 3 additions & 0 deletions tools/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const dts = require('./buildTools/dts');
const buildDemoStep = require('./buildTools/buildDemo');
const buildDocumentStep = require('./buildTools/buildDocument');
const publishStep = require('./buildTools/publish');
const buildTestStep = require('./buildTools/buildTest');
const allTasks = [
tslintStep,
cleanStep,
Expand All @@ -24,6 +25,7 @@ const allTasks = [
buildAmdStep,
buildMjsStep,
buildCommonJsStep,
buildTestStep,
pack.commonJsDebug,
pack.commonJsProduction,
pack.amdDebug,
Expand Down Expand Up @@ -56,6 +58,7 @@ const commands = [
'buildamd', // Build in AMD mode
'buildmjs', // Build in ESM/MJS mode
'buildcommonjs', // Build in CommonJs mode
'buildtest', // Build test code
'pack', // Run webpack to generate standalone .js files
'packprod', // Run webpack to generate standalone .js files in production mode
'dts', // Generate type definition files (.d.ts)
Expand Down
43 changes: 43 additions & 0 deletions tools/buildTools/buildTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
'use strict';

const fs = require('fs');
const path = require('path');
const {
runNode,
nodeModulesPath,
packagesPath,
packagesUiPath,
packagesContentModelPath,
} = require('./common');

function buildTest() {
const typescriptPath = path.join(nodeModulesPath, 'typescript/lib/tsc.js');

runNode(
typescriptPath +
` -p ${path.join(
packagesPath,
'tsconfig.test.json'
)} -t es5 --moduleResolution node -m commonjs`
);
runNode(
typescriptPath +
` -p ${path.join(
packagesUiPath,
'tsconfig.test.json'
)} -t es5 --moduleResolution node -m commonjs`
);
runNode(
typescriptPath +
` -p ${path.join(
packagesContentModelPath,
'tsconfig.test.json'
)} -t es5 --moduleResolution node -m commonjs`
);
}

module.exports = {
message: 'Building test code.',
callback: buildTest,
enabled: options => options.buildtest,
};
54 changes: 44 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1160,6 +1160,14 @@ chalk@^4.0.0:
ansi-styles "^4.1.0"
supports-color "^7.1.0"

chalk@^4.1.0:
version "4.1.2"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01"
integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==
dependencies:
ansi-styles "^4.1.0"
supports-color "^7.1.0"

"chokidar@>=3.0.0 <4.0.0", chokidar@^3.5.1:
version "3.5.3"
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.3.tgz#1cf37c8707b932bd1af1ae22c0432e2acd1903bd"
Expand Down Expand Up @@ -1786,7 +1794,7 @@ engine.io@~6.1.0:
engine.io-parser "~5.0.0"
ws "~8.2.3"

[email protected], enhanced-resolve@^4.0.0:
[email protected]:
version "4.1.0"
resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-4.1.0.tgz#41c7e0bfdfe74ac1ffe1e57ad6a5c6c9f3742a7f"
integrity sha512-F/7vkyTtyc/llOIn8oWclcB25KdRaiPBpZYDgJHgh/UHtpgT2p2eldQgtQnLtUvfMKPKxbRaQM/hHkvLHt1Vng==
Expand All @@ -1795,6 +1803,14 @@ [email protected], enhanced-resolve@^4.0.0:
memory-fs "^0.4.0"
tapable "^1.0.0"

enhanced-resolve@^5.0.0:
version "5.15.0"
resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.15.0.tgz#1af946c7d93603eb88e9896cee4904dc012e9c35"
integrity sha512-LXYT42KJ7lpIKECr2mAXIaMldcNCh/7E0KBKOu4KSfkHmP+mZmSs+8V5gBAqisWBy0OO4W5Oyys0GO1Y8KtdKg==
dependencies:
graceful-fs "^4.2.4"
tapable "^2.2.0"

enhanced-resolve@^5.14.1:
version "5.14.1"
resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.14.1.tgz#de684b6803724477a4af5d74ccae5de52c25f6b3"
Expand Down Expand Up @@ -3278,7 +3294,7 @@ loader-runner@^4.2.0:
resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-4.3.0.tgz#c1b4a163b99f614830353b16755e7149ac2314e1"
integrity sha512-3R/1M+yS3j5ou80Me59j7F9IMs4PXs3VqRrm0TU3AbKPxlmpoY1TNscJV/oGJXo8qCatFGTfDbY6W6ipGOYXfg==

[email protected], loader-utils@^1.0.2, loader-utils@^1.2.3:
[email protected], loader-utils@^1.2.3:
version "1.2.3"
resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-1.2.3.tgz#1ff5dc6911c9f0a062531a4c04b609406108c2c7"
integrity sha512-fkpz8ejdnEMG3s37wGL07iSBDg99O9D5yflE9RGNH3hRdx9SOwYfnGYdZOUIZitN8E+E2vkq3MUMYMvPYl5ZZA==
Expand Down Expand Up @@ -3348,6 +3364,13 @@ lru-cache@^5.1.1:
dependencies:
yallist "^3.0.2"

lru-cache@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94"
integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==
dependencies:
yallist "^4.0.0"

lunr@^2.3.9:
version "2.3.9"
resolved "https://registry.yarnpkg.com/lunr/-/lunr-2.3.9.tgz#18b123142832337dd6e964df1a5a7707b25d35e1"
Expand Down Expand Up @@ -4628,6 +4651,13 @@ semver@^6.0.0, semver@^6.3.0:
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4"
integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==

semver@^7.3.4:
version "7.5.4"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e"
integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==
dependencies:
lru-cache "^6.0.0"

[email protected]:
version "0.18.0"
resolved "https://registry.yarnpkg.com/send/-/send-0.18.0.tgz#670167cc654b05f5aa4a767f9113bb371bc706be"
Expand Down Expand Up @@ -5201,16 +5231,15 @@ tough-cookie@~2.4.3:
psl "^1.1.24"
punycode "^1.4.1"

ts-loader@7.0.2:
version "7.0.2"
resolved "https://registry.yarnpkg.com/ts-loader/-/ts-loader-7.0.2.tgz#465bc904aea4c331e9550e7c7d75dd17a0b7c24c"
integrity sha512-DwpZFB67RoILQHx42dMjSgv2STpacsQu5X+GD/H9ocd8IhU0m8p3b/ZrIln2KmcucC6xep2PdEMEblpWT71euA==
ts-loader@9.4.4:
version "9.4.4"
resolved "https://registry.yarnpkg.com/ts-loader/-/ts-loader-9.4.4.tgz#6ceaf4d58dcc6979f84125335904920884b7cee4"
integrity sha512-MLukxDHBl8OJ5Dk3y69IsKVFRA/6MwzEqBgh+OXMPB/OD01KQuWPFd1WAQP8a5PeSCAxfnkhiuWqfmFJzJQt9w==
dependencies:
chalk "^2.3.0"
enhanced-resolve "^4.0.0"
loader-utils "^1.0.2"
chalk "^4.1.0"
enhanced-resolve "^5.0.0"
micromatch "^4.0.0"
semver "^6.0.0"
semver "^7.3.4"

[email protected]:
version "1.9.0"
Expand Down Expand Up @@ -5735,6 +5764,11 @@ yallist@^3.0.0, yallist@^3.0.2, yallist@^3.1.1:
resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd"
integrity sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==

yallist@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72"
integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==

yaml@^1.7.2:
version "1.9.2"
resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.9.2.tgz#f0cfa865f003ab707663e4f04b3956957ea564ed"
Expand Down