From ffbea173be9feed333a817652c2dbcfacb83a799 Mon Sep 17 00:00:00 2001 From: "Joshua A. Horton" Date: Thu, 25 Apr 2024 10:52:02 +0700 Subject: [PATCH] chore(web): fixes pred-text karma config The upgrade to chai means that karma's 'framework' feature is no longer compatible, meaning a _little_ extra legwork is required to use it for karma browser tests. It's just a little bit, though. Will need to replicate this for the other packages that use karma to test, as the pattern kinda proliferated. --- .../predictive-text/unit_tests/in_browser/base.conf.cjs | 6 +++++- .../unit_tests/in_browser/cases/test-config.js | 2 +- .../unit_tests/in_browser/cases/top-level-lmlayer.js | 2 +- .../in_browser/cases/worker-dummy-integration.js | 2 +- .../in_browser/cases/worker-trie-integration.js | 2 +- .../predictive-text/unit_tests/in_browser/cases/worker.js | 2 +- common/predictive-text/unit_tests/test.sh | 8 -------- 7 files changed, 10 insertions(+), 14 deletions(-) diff --git a/common/predictive-text/unit_tests/in_browser/base.conf.cjs b/common/predictive-text/unit_tests/in_browser/base.conf.cjs index 6fa9de9f22d..4e56b520c0b 100644 --- a/common/predictive-text/unit_tests/in_browser/base.conf.cjs +++ b/common/predictive-text/unit_tests/in_browser/base.conf.cjs @@ -27,10 +27,11 @@ module.exports = { // frameworks to use // available frameworks: https://npmjs.org/browse/keyword/karma-adapter - frameworks: ['mocha', 'chai', 'fixture'], + frameworks: ['mocha', 'fixture'], // list of files / patterns to load in the browser files: [ + { pattern: 'node_modules/chai/chai.js', served: true, watched: false, included: false, type: 'module'}, // { pattern: 'node_modules/**/*.js', served: true, watched: false, included: false }, // { pattern: 'node_modules/**/*.mjs', served: true, watched: false, included: false, type: "module" }, // { pattern: 'node_modules/**/*.cjs', served: true, watched: false, included: false }, @@ -82,6 +83,9 @@ module.exports = { // enable / disable colors in the output (reporters and logs) colors: true, + // TEMP ENTRY! + reporters: ['teamcity'], + // enable / disable watching file and executing tests whenever any file changes autoWatch: true, diff --git a/common/predictive-text/unit_tests/in_browser/cases/test-config.js b/common/predictive-text/unit_tests/in_browser/cases/test-config.js index b819b5c2230..56ff6271849 100644 --- a/common/predictive-text/unit_tests/in_browser/cases/test-config.js +++ b/common/predictive-text/unit_tests/in_browser/cases/test-config.js @@ -1,4 +1,4 @@ -var assert = chai.assert; +import { assert } from '../../../../../node_modules/chai/chai.js'; /* * A canary test to ensure our timeout configurations are working correctly for our CI. diff --git a/common/predictive-text/unit_tests/in_browser/cases/top-level-lmlayer.js b/common/predictive-text/unit_tests/in_browser/cases/top-level-lmlayer.js index d2481e522ca..86e0c7db020 100644 --- a/common/predictive-text/unit_tests/in_browser/cases/top-level-lmlayer.js +++ b/common/predictive-text/unit_tests/in_browser/cases/top-level-lmlayer.js @@ -1,4 +1,4 @@ -var assert = chai.assert; +import { assert } from '../../../../../node_modules/chai/chai.js'; import { LMLayer, Worker as WorkerBuilder } from "../../../build/lib/web/index.mjs"; import * as helpers from "../helpers.mjs"; diff --git a/common/predictive-text/unit_tests/in_browser/cases/worker-dummy-integration.js b/common/predictive-text/unit_tests/in_browser/cases/worker-dummy-integration.js index b3c8ec3e9c1..e1502048097 100644 --- a/common/predictive-text/unit_tests/in_browser/cases/worker-dummy-integration.js +++ b/common/predictive-text/unit_tests/in_browser/cases/worker-dummy-integration.js @@ -1,4 +1,4 @@ -var assert = chai.assert; +import { assert } from '../../../../../node_modules/chai/chai.js'; import { LMLayer, Worker } from "../../../build/lib/web/index.mjs"; import * as helpers from "../helpers.mjs"; diff --git a/common/predictive-text/unit_tests/in_browser/cases/worker-trie-integration.js b/common/predictive-text/unit_tests/in_browser/cases/worker-trie-integration.js index c068daf8f1a..0c26628246d 100644 --- a/common/predictive-text/unit_tests/in_browser/cases/worker-trie-integration.js +++ b/common/predictive-text/unit_tests/in_browser/cases/worker-trie-integration.js @@ -1,4 +1,4 @@ -var assert = chai.assert; +import { assert } from '../../../../../node_modules/chai/chai.js'; import { LMLayer, Worker } from "../../../build/lib/web/index.mjs"; import * as helpers from "../helpers.mjs"; diff --git a/common/predictive-text/unit_tests/in_browser/cases/worker.js b/common/predictive-text/unit_tests/in_browser/cases/worker.js index 4bcb5bdc1f3..0d55aa36889 100644 --- a/common/predictive-text/unit_tests/in_browser/cases/worker.js +++ b/common/predictive-text/unit_tests/in_browser/cases/worker.js @@ -1,4 +1,4 @@ -var assert = chai.assert; +import { assert } from '../../../../../node_modules/chai/chai.js'; import { Worker as WorkerBuilder } from "../../../build/lib/web/index.mjs"; import { LMLayerWorkerCode } from "/base/common/web/lm-worker/build/lib/worker-main.wrapped.min.js"; diff --git a/common/predictive-text/unit_tests/test.sh b/common/predictive-text/unit_tests/test.sh index 577feabb99d..e27750ff997 100755 --- a/common/predictive-text/unit_tests/test.sh +++ b/common/predictive-text/unit_tests/test.sh @@ -57,14 +57,6 @@ if builder_start_action test:libraries; then "$KEYMAN_ROOT/common/models/templates/build.sh" test $TEST_OPTS popd - pushd "$KEYMAN_ROOT/common/models/types" - echo - echo "### Running $(builder_term common/models/types) tests" - # Is not mocha-based; it's TSC-based instead, as we're just ensuring that the .d.ts - # file is a proper TS declaration file. - npm run test - popd - pushd "$KEYMAN_ROOT/common/web/lm-worker" echo echo "### Running ${BUILDER_TERM_START}common/web/lm-worker${BUILDER_TERM_END} tests"