From f15342f5ee447b790a099486eccc158f028cd103 Mon Sep 17 00:00:00 2001 From: Joshua Smock Date: Fri, 17 Feb 2023 17:03:34 +0100 Subject: [PATCH 1/4] Use cljest.edn as main source of configuration for the preset Rather than requiring adding some `config.globals` value, we can use the value that comes from the config (or the default, if it's not there). --- cljest/jest.config.js | 12 --- cljest/jest.setup.js | 2 +- jest-preset-cljest/jest-preset.js | 5 ++ .../jest.cljs-transformer-process.js | 15 ++-- .../jest.dependencyExtractor.js | 8 +- .../jest.dependencyExtractor.test.js | 4 +- jest-preset-cljest/jest.globalSetup.js | 24 ++---- jest-preset-cljest/jest.hasteImpl.js | 10 +-- jest-preset-cljest/jest.hasteImpl.test.js | 4 +- jest-preset-cljest/jest.ns-watch-plugin.js | 7 +- jest-preset-cljest/jest.resolver.js | 8 +- jest-preset-cljest/utils.js | 73 +++++++++++++++---- 12 files changed, 94 insertions(+), 78 deletions(-) diff --git a/cljest/jest.config.js b/cljest/jest.config.js index c9fdf52..026faad 100644 --- a/cljest/jest.config.js +++ b/cljest/jest.config.js @@ -1,21 +1,9 @@ const path = require('path') -const { getPathsFromDepsEdn } = require('jest-preset-cljest/utils') - -const shadowOutputDir = path.resolve(__dirname, '.jest') module.exports = { setupFilesAfterEnv: [path.resolve(__dirname, 'jest.setup.js')], - testRegex: ['(.*)_spec.cljs'], - modulePaths: [shadowOutputDir], - rootDir: shadowOutputDir, - roots: getPathsFromDepsEdn(), reporters: ['default', ['jest-junit', { outputDirectory: 'reports/jest' }]], clearMocks: true, - globals: { - shadowOutputDir, - serverUrl: 'http://localhost:9111', - }, - preset: 'jest-preset-cljest', } diff --git a/cljest/jest.setup.js b/cljest/jest.setup.js index 119b69c..6584386 100644 --- a/cljest/jest.setup.js +++ b/cljest/jest.setup.js @@ -2,7 +2,7 @@ const path = require('path') const fs = require('fs') const config = require('./jest.config') -const preloadFile = path.resolve(config.globals.shadowOutputDir, 'cljest.preloads.js') +const preloadFile = path.resolve('.jest/cljest.preloads.js') // The preloads files may not exist if the initial compilation failed if (fs.existsSync(preloadFile)) { diff --git a/jest-preset-cljest/jest-preset.js b/jest-preset-cljest/jest-preset.js index 94c04a6..55b361d 100644 --- a/jest-preset-cljest/jest-preset.js +++ b/jest-preset-cljest/jest-preset.js @@ -1,6 +1,9 @@ const path = require('path') +const { getBuildDir, getPathsFromCljestConfig, generateTestRegexes } = require('./utils') + module.exports = { + testRegex: generateTestRegexes(), moduleFileExtensions: ['clj', 'cljs', 'js'], globalSetup: path.resolve(__dirname, 'jest.globalSetup.js'), resolver: path.resolve(__dirname, 'jest.resolver.js'), @@ -12,4 +15,6 @@ module.exports = { haste: { hasteImplModulePath: path.resolve(__dirname, 'jest.hasteImpl.js'), }, + modulePaths: [getBuildDir()], + roots: getPathsFromCljestConfig(), } diff --git a/jest-preset-cljest/jest.cljs-transformer-process.js b/jest-preset-cljest/jest.cljs-transformer-process.js index bca891d..f27ec62 100644 --- a/jest-preset-cljest/jest.cljs-transformer-process.js +++ b/jest-preset-cljest/jest.cljs-transformer-process.js @@ -2,11 +2,10 @@ const { runAsWorker } = require('synckit') const fetch = require('node-fetch') const path = require('path') const fs = require('fs') -const { getProjectConfig } = require('./utils') +const { getServerUrl, getBuildDir } = require('./utils') -const { - globals: { shadowOutputDir, serverUrl }, -} = getProjectConfig() +const serverUrl = getServerUrl() +const buildDir = getBuildDir() function getPrecompiledFile(sourceText) { const namespace = sourceText.match(/ns\s([\w\.\-]+)/)[1] @@ -14,8 +13,8 @@ function getPrecompiledFile(sourceText) { return { status: 'success', - code: fs.readFileSync(path.resolve(shadowOutputDir, filename)).toString(), - map: fs.readFileSync(path.resolve(shadowOutputDir, `${filename}.map`)).toString(), + code: fs.readFileSync(path.resolve(buildDir, filename)).toString(), + map: fs.readFileSync(path.resolve(buildDir, `${filename}.map`)).toString(), } } @@ -42,8 +41,8 @@ async function getServerCompiledFile(sourceText, sourcePath) { return { status: 'success', - code: fs.readFileSync(path.resolve(shadowOutputDir, filename)).toString(), - map: fs.readFileSync(path.resolve(shadowOutputDir, `${filename}.map`)).toString(), + code: fs.readFileSync(path.resolve(buildDir, filename)).toString(), + map: fs.readFileSync(path.resolve(buildDir, `${filename}.map`)).toString(), } } diff --git a/jest-preset-cljest/jest.dependencyExtractor.js b/jest-preset-cljest/jest.dependencyExtractor.js index ece6993..3983453 100644 --- a/jest-preset-cljest/jest.dependencyExtractor.js +++ b/jest-preset-cljest/jest.dependencyExtractor.js @@ -1,8 +1,6 @@ -const { getProjectConfig } = require('./utils') const fs = require('fs') const crypto = require('crypto') - -const { roots } = getProjectConfig() +const { getPathsFromCljestConfig } = require('./utils') function getDependenciesFromTokens(tokens) { const result = [] @@ -99,7 +97,9 @@ function getDepsForOpening(code, opening) { module.exports = { extract(code, filePath) { - if (!roots.some((root) => filePath.startsWith(root))) { + const testSrcPaths = getPathsFromCljestConfig() + + if (!testSrcPaths.some((p) => filePath.startsWith(p))) { return [] } diff --git a/jest-preset-cljest/jest.dependencyExtractor.test.js b/jest-preset-cljest/jest.dependencyExtractor.test.js index 365624f..fdb408c 100644 --- a/jest-preset-cljest/jest.dependencyExtractor.test.js +++ b/jest-preset-cljest/jest.dependencyExtractor.test.js @@ -1,9 +1,7 @@ const dependencyExtractor = require('./jest.dependencyExtractor') jest.mock('./utils', () => ({ - getProjectConfig: () => ({ - roots: ['/root_a', '/root_b'], - }), + getPathsFromCljestConfig: () => ['/root_a', '/root_b'], })) describe('extract', () => { diff --git a/jest-preset-cljest/jest.globalSetup.js b/jest-preset-cljest/jest.globalSetup.js index 7c8a03c..2623afd 100644 --- a/jest-preset-cljest/jest.globalSetup.js +++ b/jest-preset-cljest/jest.globalSetup.js @@ -1,34 +1,20 @@ const fetch = require('node-fetch') -const { getProjectConfig } = require('./utils') +const { getServerUrl } = require('./utils') -async function fetchUntilAvailable(serverUrl) { +async function fetchUntilAvailable() { if (process.env.CI) { return } try { - await fetch(`${serverUrl}/compile`) + await fetch(`${getServerUrl()}/compile`) } catch (_) { await new Promise((resolve) => setTimeout(resolve, 50)) - return fetchUntilAvailable(serverUrl) + return fetchUntilAvailable() } } module.exports = async function globalSetup() { - const { globals } = await getProjectConfig() - - if (!globals.shadowOutputDir) { - throw new Error( - 'config.globals.shadowOutputDir must be set to the output-dir of your :jest shadow-cljs.edn build.' - ) - } - - if (!globals.serverUrl) { - throw new Error( - 'config.globals.serverUrl must be set to the server URL of the shadow compilation server. E.g. http://localhost:9001' - ) - } - - await fetchUntilAvailable(globals.serverUrl) + await fetchUntilAvailable() } diff --git a/jest-preset-cljest/jest.hasteImpl.js b/jest-preset-cljest/jest.hasteImpl.js index 84ccd54..4423316 100644 --- a/jest-preset-cljest/jest.hasteImpl.js +++ b/jest-preset-cljest/jest.hasteImpl.js @@ -1,14 +1,14 @@ -const { getProjectConfig } = require('./utils') +const { getPathsFromCljestConfig } = require('./utils') -const { roots } = getProjectConfig() +const paths = getPathsFromCljestConfig() module.exports = { getHasteName(filePath) { - const root = roots.find((root) => filePath.startsWith(root)) + const foundPath = paths.find((root) => filePath.startsWith(root)) - if (root) { + if (foundPath) { const baseHasteName = filePath - .split(`${root}/`)[1] + .split(`${foundPath}/`)[1] .replace(/\.clj(s|c)?/, '') .replace(/\_/g, '-') .replace(/\//g, '.') diff --git a/jest-preset-cljest/jest.hasteImpl.test.js b/jest-preset-cljest/jest.hasteImpl.test.js index 2b9430e..77d0330 100644 --- a/jest-preset-cljest/jest.hasteImpl.test.js +++ b/jest-preset-cljest/jest.hasteImpl.test.js @@ -1,9 +1,7 @@ const hasteImpl = require('./jest.hasteImpl') jest.mock('./utils', () => ({ - getProjectConfig: () => ({ - roots: ['/root_a', '/root_b'], - }), + getPathsFromCljestConfig: () => ['/root_a', '/root_b'], })) describe('getHasteName', () => { diff --git a/jest-preset-cljest/jest.ns-watch-plugin.js b/jest-preset-cljest/jest.ns-watch-plugin.js index c9a2ff6..33237dd 100644 --- a/jest-preset-cljest/jest.ns-watch-plugin.js +++ b/jest-preset-cljest/jest.ns-watch-plugin.js @@ -6,9 +6,10 @@ const { } = require('jest-watcher') const chalk = require('chalk') const fs = require('fs') -const { getProjectConfig } = require('./utils') +const { generateTestRegexes, getPathsFromCljestConfig } = require('./utils') -const { roots, testRegex } = getProjectConfig() +const roots = getPathsFromCljestConfig() +const testRegexes = generateTestRegexes() function* traverseDirectory(dir) { const dirents = fs.readdirSync(dir, { withFileTypes: true }) @@ -81,7 +82,7 @@ class NamespaceWatchPlugin { const possibleNamespaces = roots.reduce((acc, root) => { // Assume root is absolute path for (const filename of traverseDirectory(root)) { - if (testRegex.some((regex) => new RegExp(regex).test(filename))) { + if (testRegexes.some((regex) => new RegExp(regex).test(filename))) { acc.push( filename.replace(`${root}/`, '').slice(0, -5).replace(/_/g, '-').replace(/\//g, '.') ) diff --git a/jest-preset-cljest/jest.resolver.js b/jest-preset-cljest/jest.resolver.js index e4af8c3..78ee997 100644 --- a/jest-preset-cljest/jest.resolver.js +++ b/jest-preset-cljest/jest.resolver.js @@ -1,15 +1,13 @@ const path = require('path') -const { getProjectConfig } = require('./utils') +const { getBuildDir } = require('./utils') -const { - globals: { shadowOutputDir }, -} = getProjectConfig() +const buildDir = getBuildDir() module.exports = function (filePath, options) { try { return options.defaultResolver(filePath, options) } catch (e) { - const absPath = path.resolve(shadowOutputDir, filePath) + const absPath = path.resolve(buildDir, filePath) return options.defaultResolver(absPath, options) } diff --git a/jest-preset-cljest/utils.js b/jest-preset-cljest/utils.js index 4d2b7da..5ff312f 100644 --- a/jest-preset-cljest/utils.js +++ b/jest-preset-cljest/utils.js @@ -4,28 +4,71 @@ const { parseEDNString } = require('edn-data') const jestProjectDir = process.cwd() -function getProjectConfig() { - if (!jestProjectDir) { - throw new Error( - 'Jest should be run from a project directory, which contains a file called jest.config.js' - ) - } - +function ensureProjectConfig() { const dirents = fs.readdirSync(jestProjectDir, { withFileTypes: true }) if (!dirents.some((dirent) => dirent.name === 'jest.config.js')) { - throw new Error(`Could not locate a file named jest.config.js in ${jestProjectDir}`) + throw new Error(`Could not locate a file named jest.config.js in ${jestProjectDir}.`) } - return require(path.join(jestProjectDir, 'jest.config.js')) + if (!dirents.some((dirent) => dirent.name === 'cljest.edn')) { + throw new Error(`Could not locate a file named cljest.edn in ${jestProjectDir}.`) + } } -function getPathsFromDepsEdn() { - const depsEdnFile = path.resolve(jestProjectDir, 'deps.edn') - const rawDepsEdn = fs.readFileSync(depsEdnFile).toString() - const { paths } = parseEDNString(rawDepsEdn, { mapAs: 'object', keywordAs: 'string' }) +function withEnsuredProjectConfig(fn) { + return function (...args) { + ensureProjectConfig() + + return fn(...args) + } +} + +const getRootDir = withEnsuredProjectConfig(() => jestProjectDir) +const getBuildDir = withEnsuredProjectConfig(() => path.resolve(jestProjectDir, '.jest')) +const getJestConfig = withEnsuredProjectConfig(() => require(path.join(jestProjectDir, 'jest.config.js'))) +const getCljestConfig = withEnsuredProjectConfig(() => { + const configPath = path.resolve(jestProjectDir, 'cljest.edn') + const rawCljestConfig = fs.readFileSync(configPath).toString() + + return parseEDNString(rawCljestConfig, { mapAs: 'object', keywordAs: 'string' }) +}) + +const getPathsFromCljestConfig = withEnsuredProjectConfig(() => { + const { 'test-src-dirs': testSrcDirs } = getCljestConfig() - return paths.map((p) => path.resolve(jestProjectDir, p)) + return testSrcDirs.map((p) => path.resolve(jestProjectDir, p)) +}) + +const getServerUrl = withEnsuredProjectConfig(() => { + const { port } = getCljestConfig() + + if (!port) { + return `http://localhost:9003` + } + + return `http://localhost:${parseInt(port, 10)}` +}) + +function generateTestRegexes() { + const { 'ns-suffixes': raw } = getCljestConfig() + let nsSuffixes; + + if (!raw) { + nsSuffixes = ['_test'] + } else { + nsSuffixes = raw.map(({ sym: suffix }) => suffix.replace(/-/g, '_')) + } + + return nsSuffixes.map(suffix => `(.*)${suffix}.cljs`) } -module.exports = { getProjectConfig, getPathsFromDepsEdn } +module.exports = { + getRootDir, + getBuildDir, + getServerUrl, + getJestConfig, + getCljestConfig, + getPathsFromCljestConfig, + generateTestRegexes +} From 6cffadc707c53597f1d2442a7dc225b396d39194 Mon Sep 17 00:00:00 2001 From: Joshua Smock Date: Fri, 17 Feb 2023 17:10:57 +0100 Subject: [PATCH 2/4] Support port value in cljest.edn --- cljest/package.json | 2 +- cljest/src/cljest/compilation.clj | 9 +++-- cljest/src/cljest/compilation/config.clj | 4 +++ cljest/src/cljest/compilation/server.clj | 44 +++++++++++++----------- 4 files changed, 32 insertions(+), 27 deletions(-) diff --git a/cljest/package.json b/cljest/package.json index 4a28222..f647c43 100644 --- a/cljest/package.json +++ b/cljest/package.json @@ -5,7 +5,7 @@ "scripts": { "jest:watch": "jest --watch", "jest:ci": "CI=true jest --ci", - "jest:server": "clj -X cljest.compilation/watch :port 9111", + "jest:server": "clj -X cljest.compilation/watch", "jest:compile": "clj -X cljest.compilation/compile", "publish": "clj -M -m deps-library.release" }, diff --git a/cljest/src/cljest/compilation.clj b/cljest/src/cljest/compilation.clj index 26c86be..2647353 100644 --- a/cljest/src/cljest/compilation.clj +++ b/cljest/src/cljest/compilation.clj @@ -30,9 +30,9 @@ (defn watch "Runs cljest in watch mode, which starts a server and compiles test files on demand." - [{:keys [port]}] + [{}] (setup!) - (server/start-server! port)) + (server/start-server!)) (defn compile [_] @@ -41,6 +41,5 @@ (defn -main "An alias for watch mode." - [raw-port] - (let [port (Integer/parseInt raw-port)] - (watch {:port port}))) + [] + (watch {})) diff --git a/cljest/src/cljest/compilation/config.clj b/cljest/src/cljest/compilation/config.clj index 03fba14..ad12666 100644 --- a/cljest/src/cljest/compilation/config.clj +++ b/cljest/src/cljest/compilation/config.clj @@ -14,6 +14,7 @@ [:compiler-options {:optional true} [:map {:closed true} [:closure-defines :map]]] + [:port {:default 9003} :int] [:test-src-dirs [:sequential :string]] [:ns-suffixes [:sequential {:default ['-test]} :symbol]] [:mode [:enum {:error/message "only :all is allowed" :default :all} :all]] @@ -54,6 +55,9 @@ (and (= :string (malli/type schema)) (not (string? value))) (str "The value at " pretty-path " should be a string but is not. Value: " pretty-value) + (and (= :int (malli/type schema)) (not (int? value))) + (str "The value at " pretty-path " should be an integer but is not. Value: " pretty-value) + (and (= :symbol (malli/type schema)) (not (symbol? value))) (str "The value at " pretty-path " should be a symbol but is not. Value: " pretty-value) diff --git a/cljest/src/cljest/compilation/server.clj b/cljest/src/cljest/compilation/server.clj index 4c055c1..2f56907 100644 --- a/cljest/src/cljest/compilation/server.clj +++ b/cljest/src/cljest/compilation/server.clj @@ -1,5 +1,6 @@ (ns cljest.compilation.server (:require [cheshire.core :as cheshire] + [cljest.compilation.config :as config] [cljest.compilation.fs :as fs] [cljest.compilation.shadow :as shadow] [clojure.core.async :as as] @@ -93,27 +94,28 @@ {:status 404})) (defn start-server! - [port] + [] (shadow/start-server!) (fs/setup-watchers!) - (log/infof "Starting Jest compilation server") - (log/infof "HTTP server at http://localhost:%s" port) - - ; Run both async to not block, and run both in general to update the build status after - ; the initial watch. - ; - ; In regular operation with Jest, this probably wouldn't happen because it would call - ; `/compile` immediately (and before watching finishes), but in general, without calling - ; `compile-and-update-build-status!` before the initial watch finishes, the status would - ; never update from `:unknown` and any subsequent `/compile` API call would hang. - (as/go (compile-and-update-build-status!)) - (as/go (shadow/start-watching)) - - (run-jetty - (-> handler - (wrap-defaults site-defaults) - (wrap-resource "") - (wrap-params)) - {:port port - :join? false})) + (let [{:keys [port]} (config/get-config!)] + (log/infof "Starting Jest compilation server") + (log/infof "HTTP server at http://localhost:%s" port) + + ; Run both async to not block, and run both in general to update the build status after + ; the initial watch. + ; + ; In regular operation with Jest, this probably wouldn't happen because it would call + ; `/compile` immediately (and before watching finishes), but in general, without calling + ; `compile-and-update-build-status!` before the initial watch finishes, the status would + ; never update from `:unknown` and any subsequent `/compile` API call would hang. + (as/go (compile-and-update-build-status!)) + (as/go (shadow/start-watching)) + + (run-jetty + (-> handler + (wrap-defaults site-defaults) + (wrap-resource "") + (wrap-params)) + {:port port + :join? false}))) From 4709ca02454576dbb793c48d73c413de398e5da2 Mon Sep 17 00:00:00 2001 From: Joshua Smock Date: Fri, 17 Feb 2023 17:24:48 +0100 Subject: [PATCH 3/4] Commit using the local version to simplify development --- cljest/package-lock.json | 521 ++------------------------------------- cljest/package.json | 2 +- 2 files changed, 27 insertions(+), 496 deletions(-) diff --git a/cljest/package-lock.json b/cljest/package-lock.json index 7f43092..c24931d 100644 --- a/cljest/package-lock.json +++ b/cljest/package-lock.json @@ -11,7 +11,25 @@ "devDependencies": { "jest": "^29.2.1", "jest-junit": "^14.0.1", - "jest-preset-cljest": "^0.9.0-alpha1" + "jest-preset-cljest": "file:../jest-preset-cljest" + } + }, + "../jest-preset-cljest": { + "version": "0.9.0-alpha1", + "dev": true, + "license": "MIT", + "dependencies": { + "chalk": "4.1.2", + "edn-data": "^0.2.0", + "jest-watcher": "^28.0.2", + "node-fetch": "2.6.1", + "synckit": "^0.7.0" + }, + "devDependencies": { + "eslint": "^8.27.0", + "eslint-plugin-jest": "^27.1.5", + "jest": "^29.3.1", + "jest-junit": "^14.0.1" } }, "node_modules/@ampproject/remapping": { @@ -747,17 +765,6 @@ } } }, - "node_modules/@jest/schemas": { - "version": "28.1.3", - "dev": true, - "license": "MIT", - "dependencies": { - "@sinclair/typebox": "^0.24.1" - }, - "engines": { - "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0" - } - }, "node_modules/@jest/source-map": { "version": "29.2.0", "dev": true, @@ -894,25 +901,6 @@ "@jridgewell/sourcemap-codec": "1.4.14" } }, - "node_modules/@pkgr/utils": { - "version": "2.3.1", - "dev": true, - "license": "MIT", - "dependencies": { - "cross-spawn": "^7.0.3", - "is-glob": "^4.0.3", - "open": "^8.4.0", - "picocolors": "^1.0.0", - "tiny-glob": "^0.2.9", - "tslib": "^2.4.0" - }, - "engines": { - "node": "^12.20.0 || ^14.18.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/unts" - } - }, "node_modules/@sinclair/typebox": { "version": "0.24.47", "dev": true, @@ -1397,14 +1385,6 @@ "node": ">=0.10.0" } }, - "node_modules/define-lazy-prop": { - "version": "2.0.0", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, "node_modules/detect-newline": { "version": "3.1.0", "dev": true, @@ -1421,11 +1401,6 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, - "node_modules/edn-data": { - "version": "0.2.0", - "dev": true, - "license": "MIT" - }, "node_modules/electron-to-chromium": { "version": "1.4.284", "dev": true, @@ -1647,16 +1622,6 @@ "node": ">=4" } }, - "node_modules/globalyzer": { - "version": "0.1.0", - "dev": true, - "license": "MIT" - }, - "node_modules/globrex": { - "version": "0.1.2", - "dev": true, - "license": "MIT" - }, "node_modules/graceful-fs": { "version": "4.2.10", "dev": true, @@ -1750,28 +1715,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-docker": { - "version": "2.2.1", - "dev": true, - "license": "MIT", - "bin": { - "is-docker": "cli.js" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/is-extglob": { - "version": "2.1.1", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/is-fullwidth-code-point": { "version": "3.0.0", "dev": true, @@ -1788,17 +1731,6 @@ "node": ">=6" } }, - "node_modules/is-glob": { - "version": "4.0.3", - "dev": true, - "license": "MIT", - "dependencies": { - "is-extglob": "^2.1.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/is-number": { "version": "7.0.0", "dev": true, @@ -1818,17 +1750,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/is-wsl": { - "version": "2.2.0", - "dev": true, - "license": "MIT", - "dependencies": { - "is-docker": "^2.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/isexe": { "version": "2.0.0", "dev": true, @@ -2215,149 +2136,8 @@ } }, "node_modules/jest-preset-cljest": { - "version": "0.9.0-alpha1", - "resolved": "https://registry.npmjs.org/jest-preset-cljest/-/jest-preset-cljest-0.9.0-alpha1.tgz", - "integrity": "sha512-bUaGpE0BjcLtLQ/n4dwvNJ2yHmpaHLUNUI2IBPo6ay1NVojsfuVfhOlKgpt2M16huKnkUVO6NzR484ohq0gJmQ==", - "dev": true, - "dependencies": { - "chalk": "4.1.2", - "edn-data": "^0.2.0", - "jest-watcher": "^28.0.2", - "node-fetch": "2.6.1", - "synckit": "^0.7.0" - } - }, - "node_modules/jest-preset-cljest/node_modules/@jest/console": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/@jest/console/-/console-28.1.3.tgz", - "integrity": "sha512-QPAkP5EwKdK/bxIr6C1I4Vs0rm2nHiANzj/Z5X2JQkrZo6IqvC4ldZ9K95tF0HdidhA8Bo6egxSzUFPYKcEXLw==", - "dev": true, - "dependencies": { - "@jest/types": "^28.1.3", - "@types/node": "*", - "chalk": "^4.0.0", - "jest-message-util": "^28.1.3", - "jest-util": "^28.1.3", - "slash": "^3.0.0" - }, - "engines": { - "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0" - } - }, - "node_modules/jest-preset-cljest/node_modules/@jest/test-result": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/@jest/test-result/-/test-result-28.1.3.tgz", - "integrity": "sha512-kZAkxnSE+FqE8YjW8gNuoVkkC9I7S1qmenl8sGcDOLropASP+BkcGKwhXoyqQuGOGeYY0y/ixjrd/iERpEXHNg==", - "dev": true, - "dependencies": { - "@jest/console": "^28.1.3", - "@jest/types": "^28.1.3", - "@types/istanbul-lib-coverage": "^2.0.0", - "collect-v8-coverage": "^1.0.0" - }, - "engines": { - "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0" - } - }, - "node_modules/jest-preset-cljest/node_modules/@jest/types": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-28.1.3.tgz", - "integrity": "sha512-RyjiyMUZrKz/c+zlMFO1pm70DcIlST8AeWTkoUdZevew44wcNZQHsEVOiCVtgVnlFFD82FPaXycys58cf2muVQ==", - "dev": true, - "dependencies": { - "@jest/schemas": "^28.1.3", - "@types/istanbul-lib-coverage": "^2.0.0", - "@types/istanbul-reports": "^3.0.0", - "@types/node": "*", - "@types/yargs": "^17.0.8", - "chalk": "^4.0.0" - }, - "engines": { - "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0" - } - }, - "node_modules/jest-preset-cljest/node_modules/ansi-styles": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", - "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", - "dev": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/jest-preset-cljest/node_modules/jest-message-util": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-28.1.3.tgz", - "integrity": "sha512-PFdn9Iewbt575zKPf1286Ht9EPoJmYT7P0kY+RibeYZ2XtOr53pDLEFoTWXbd1h4JiGiWpTBC84fc8xMXQMb7g==", - "dev": true, - "dependencies": { - "@babel/code-frame": "^7.12.13", - "@jest/types": "^28.1.3", - "@types/stack-utils": "^2.0.0", - "chalk": "^4.0.0", - "graceful-fs": "^4.2.9", - "micromatch": "^4.0.4", - "pretty-format": "^28.1.3", - "slash": "^3.0.0", - "stack-utils": "^2.0.3" - }, - "engines": { - "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0" - } - }, - "node_modules/jest-preset-cljest/node_modules/jest-util": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-28.1.3.tgz", - "integrity": "sha512-XdqfpHwpcSRko/C35uLYFM2emRAltIIKZiJ9eAmhjsj0CqZMa0p1ib0R5fWIqGhn1a103DebTbpqIaP1qCQ6tQ==", - "dev": true, - "dependencies": { - "@jest/types": "^28.1.3", - "@types/node": "*", - "chalk": "^4.0.0", - "ci-info": "^3.2.0", - "graceful-fs": "^4.2.9", - "picomatch": "^2.2.3" - }, - "engines": { - "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0" - } - }, - "node_modules/jest-preset-cljest/node_modules/jest-watcher": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/jest-watcher/-/jest-watcher-28.1.3.tgz", - "integrity": "sha512-t4qcqj9hze+jviFPUN3YAtAEeFnr/azITXQEMARf5cMwKY2SMBRnCQTXLixTl20OR6mLh9KLMrgVJgJISym+1g==", - "dev": true, - "dependencies": { - "@jest/test-result": "^28.1.3", - "@jest/types": "^28.1.3", - "@types/node": "*", - "ansi-escapes": "^4.2.1", - "chalk": "^4.0.0", - "emittery": "^0.10.2", - "jest-util": "^28.1.3", - "string-length": "^4.0.1" - }, - "engines": { - "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0" - } - }, - "node_modules/jest-preset-cljest/node_modules/pretty-format": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-28.1.3.tgz", - "integrity": "sha512-8gFb/To0OmxHR9+ZTb14Df2vNxdGCX8g1xWGUTqUw5TiZvcQf5sHKObd5UcPyLLyowNwDAMTF3XWOG1B6mxl1Q==", - "dev": true, - "dependencies": { - "@jest/schemas": "^28.1.3", - "ansi-regex": "^5.0.1", - "ansi-styles": "^5.0.0", - "react-is": "^18.0.0" - }, - "engines": { - "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0" - } + "resolved": "../jest-preset-cljest", + "link": true }, "node_modules/jest-regex-util": { "version": "29.2.0", @@ -2753,14 +2533,6 @@ "dev": true, "license": "MIT" }, - "node_modules/node-fetch": { - "version": "2.6.1", - "dev": true, - "license": "MIT", - "engines": { - "node": "4.x || >=6.0.0" - } - }, "node_modules/node-int64": { "version": "0.4.0", "dev": true, @@ -2812,22 +2584,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/open": { - "version": "8.4.0", - "dev": true, - "license": "MIT", - "dependencies": { - "define-lazy-prop": "^2.0.0", - "is-docker": "^2.1.1", - "is-wsl": "^2.2.0" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/p-limit": { "version": "3.1.0", "dev": true, @@ -3222,21 +2978,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/synckit": { - "version": "0.7.3", - "dev": true, - "license": "MIT", - "dependencies": { - "@pkgr/utils": "^2.3.0", - "tslib": "^2.4.0" - }, - "engines": { - "node": "^12.20.0 || ^14.18.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/unts" - } - }, "node_modules/test-exclude": { "version": "6.0.0", "dev": true, @@ -3250,15 +2991,6 @@ "node": ">=8" } }, - "node_modules/tiny-glob": { - "version": "0.2.9", - "dev": true, - "license": "MIT", - "dependencies": { - "globalyzer": "0.1.0", - "globrex": "^0.1.2" - } - }, "node_modules/tmpl": { "version": "1.0.5", "dev": true, @@ -3283,11 +3015,6 @@ "node": ">=8.0" } }, - "node_modules/tslib": { - "version": "2.4.1", - "dev": true, - "license": "0BSD" - }, "node_modules/type-detect": { "version": "4.0.8", "dev": true, @@ -3949,13 +3676,6 @@ "v8-to-istanbul": "^9.0.1" } }, - "@jest/schemas": { - "version": "28.1.3", - "dev": true, - "requires": { - "@sinclair/typebox": "^0.24.1" - } - }, "@jest/source-map": { "version": "29.2.0", "dev": true, @@ -4056,18 +3776,6 @@ "@jridgewell/sourcemap-codec": "1.4.14" } }, - "@pkgr/utils": { - "version": "2.3.1", - "dev": true, - "requires": { - "cross-spawn": "^7.0.3", - "is-glob": "^4.0.3", - "open": "^8.4.0", - "picocolors": "^1.0.0", - "tiny-glob": "^0.2.9", - "tslib": "^2.4.0" - } - }, "@sinclair/typebox": { "version": "0.24.47", "dev": true @@ -4392,10 +4100,6 @@ "version": "4.2.2", "dev": true }, - "define-lazy-prop": { - "version": "2.0.0", - "dev": true - }, "detect-newline": { "version": "3.1.0", "dev": true @@ -4404,10 +4108,6 @@ "version": "29.2.0", "dev": true }, - "edn-data": { - "version": "0.2.0", - "dev": true - }, "electron-to-chromium": { "version": "1.4.284", "dev": true @@ -4540,14 +4240,6 @@ "version": "11.12.0", "dev": true }, - "globalyzer": { - "version": "0.1.0", - "dev": true - }, - "globrex": { - "version": "0.1.2", - "dev": true - }, "graceful-fs": { "version": "4.2.10", "dev": true @@ -4606,14 +4298,6 @@ "has": "^1.0.3" } }, - "is-docker": { - "version": "2.2.1", - "dev": true - }, - "is-extglob": { - "version": "2.1.1", - "dev": true - }, "is-fullwidth-code-point": { "version": "3.0.0", "dev": true @@ -4622,13 +4306,6 @@ "version": "2.1.0", "dev": true }, - "is-glob": { - "version": "4.0.3", - "dev": true, - "requires": { - "is-extglob": "^2.1.1" - } - }, "is-number": { "version": "7.0.0", "dev": true @@ -4637,13 +4314,6 @@ "version": "2.0.1", "dev": true }, - "is-wsl": { - "version": "2.2.0", - "dev": true, - "requires": { - "is-docker": "^2.0.0" - } - }, "isexe": { "version": "2.0.0", "dev": true @@ -4898,123 +4568,17 @@ "requires": {} }, "jest-preset-cljest": { - "version": "0.9.0-alpha1", - "resolved": "https://registry.npmjs.org/jest-preset-cljest/-/jest-preset-cljest-0.9.0-alpha1.tgz", - "integrity": "sha512-bUaGpE0BjcLtLQ/n4dwvNJ2yHmpaHLUNUI2IBPo6ay1NVojsfuVfhOlKgpt2M16huKnkUVO6NzR484ohq0gJmQ==", - "dev": true, + "version": "file:../jest-preset-cljest", "requires": { "chalk": "4.1.2", "edn-data": "^0.2.0", + "eslint": "^8.27.0", + "eslint-plugin-jest": "^27.1.5", + "jest": "^29.3.1", + "jest-junit": "^14.0.1", "jest-watcher": "^28.0.2", "node-fetch": "2.6.1", "synckit": "^0.7.0" - }, - "dependencies": { - "@jest/console": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/@jest/console/-/console-28.1.3.tgz", - "integrity": "sha512-QPAkP5EwKdK/bxIr6C1I4Vs0rm2nHiANzj/Z5X2JQkrZo6IqvC4ldZ9K95tF0HdidhA8Bo6egxSzUFPYKcEXLw==", - "dev": true, - "requires": { - "@jest/types": "^28.1.3", - "@types/node": "*", - "chalk": "^4.0.0", - "jest-message-util": "^28.1.3", - "jest-util": "^28.1.3", - "slash": "^3.0.0" - } - }, - "@jest/test-result": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/@jest/test-result/-/test-result-28.1.3.tgz", - "integrity": "sha512-kZAkxnSE+FqE8YjW8gNuoVkkC9I7S1qmenl8sGcDOLropASP+BkcGKwhXoyqQuGOGeYY0y/ixjrd/iERpEXHNg==", - "dev": true, - "requires": { - "@jest/console": "^28.1.3", - "@jest/types": "^28.1.3", - "@types/istanbul-lib-coverage": "^2.0.0", - "collect-v8-coverage": "^1.0.0" - } - }, - "@jest/types": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/@jest/types/-/types-28.1.3.tgz", - "integrity": "sha512-RyjiyMUZrKz/c+zlMFO1pm70DcIlST8AeWTkoUdZevew44wcNZQHsEVOiCVtgVnlFFD82FPaXycys58cf2muVQ==", - "dev": true, - "requires": { - "@jest/schemas": "^28.1.3", - "@types/istanbul-lib-coverage": "^2.0.0", - "@types/istanbul-reports": "^3.0.0", - "@types/node": "*", - "@types/yargs": "^17.0.8", - "chalk": "^4.0.0" - } - }, - "ansi-styles": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", - "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", - "dev": true - }, - "jest-message-util": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-28.1.3.tgz", - "integrity": "sha512-PFdn9Iewbt575zKPf1286Ht9EPoJmYT7P0kY+RibeYZ2XtOr53pDLEFoTWXbd1h4JiGiWpTBC84fc8xMXQMb7g==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.12.13", - "@jest/types": "^28.1.3", - "@types/stack-utils": "^2.0.0", - "chalk": "^4.0.0", - "graceful-fs": "^4.2.9", - "micromatch": "^4.0.4", - "pretty-format": "^28.1.3", - "slash": "^3.0.0", - "stack-utils": "^2.0.3" - } - }, - "jest-util": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-28.1.3.tgz", - "integrity": "sha512-XdqfpHwpcSRko/C35uLYFM2emRAltIIKZiJ9eAmhjsj0CqZMa0p1ib0R5fWIqGhn1a103DebTbpqIaP1qCQ6tQ==", - "dev": true, - "requires": { - "@jest/types": "^28.1.3", - "@types/node": "*", - "chalk": "^4.0.0", - "ci-info": "^3.2.0", - "graceful-fs": "^4.2.9", - "picomatch": "^2.2.3" - } - }, - "jest-watcher": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/jest-watcher/-/jest-watcher-28.1.3.tgz", - "integrity": "sha512-t4qcqj9hze+jviFPUN3YAtAEeFnr/azITXQEMARf5cMwKY2SMBRnCQTXLixTl20OR6mLh9KLMrgVJgJISym+1g==", - "dev": true, - "requires": { - "@jest/test-result": "^28.1.3", - "@jest/types": "^28.1.3", - "@types/node": "*", - "ansi-escapes": "^4.2.1", - "chalk": "^4.0.0", - "emittery": "^0.10.2", - "jest-util": "^28.1.3", - "string-length": "^4.0.1" - } - }, - "pretty-format": { - "version": "28.1.3", - "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-28.1.3.tgz", - "integrity": "sha512-8gFb/To0OmxHR9+ZTb14Df2vNxdGCX8g1xWGUTqUw5TiZvcQf5sHKObd5UcPyLLyowNwDAMTF3XWOG1B6mxl1Q==", - "dev": true, - "requires": { - "@jest/schemas": "^28.1.3", - "ansi-regex": "^5.0.1", - "ansi-styles": "^5.0.0", - "react-is": "^18.0.0" - } - } } }, "jest-regex-util": { @@ -5294,10 +4858,6 @@ "version": "1.4.0", "dev": true }, - "node-fetch": { - "version": "2.6.1", - "dev": true - }, "node-int64": { "version": "0.4.0", "dev": true @@ -5331,15 +4891,6 @@ "mimic-fn": "^2.1.0" } }, - "open": { - "version": "8.4.0", - "dev": true, - "requires": { - "define-lazy-prop": "^2.0.0", - "is-docker": "^2.1.1", - "is-wsl": "^2.2.0" - } - }, "p-limit": { "version": "3.1.0", "dev": true, @@ -5571,14 +5122,6 @@ "version": "1.0.0", "dev": true }, - "synckit": { - "version": "0.7.3", - "dev": true, - "requires": { - "@pkgr/utils": "^2.3.0", - "tslib": "^2.4.0" - } - }, "test-exclude": { "version": "6.0.0", "dev": true, @@ -5588,14 +5131,6 @@ "minimatch": "^3.0.4" } }, - "tiny-glob": { - "version": "0.2.9", - "dev": true, - "requires": { - "globalyzer": "0.1.0", - "globrex": "^0.1.2" - } - }, "tmpl": { "version": "1.0.5", "dev": true @@ -5611,10 +5146,6 @@ "is-number": "^7.0.0" } }, - "tslib": { - "version": "2.4.1", - "dev": true - }, "type-detect": { "version": "4.0.8", "dev": true diff --git a/cljest/package.json b/cljest/package.json index f647c43..d1bb79c 100644 --- a/cljest/package.json +++ b/cljest/package.json @@ -14,6 +14,6 @@ "devDependencies": { "jest": "^29.2.1", "jest-junit": "^14.0.1", - "jest-preset-cljest": "^0.9.0-alpha1" + "jest-preset-cljest": "file:../jest-preset-cljest" } } From d7630954bfbf6dc6cc220e517a8e0ee0cd5776b6 Mon Sep 17 00:00:00 2001 From: Joshua Smock Date: Mon, 20 Feb 2023 12:32:40 +0100 Subject: [PATCH 4/4] Link jest-preset-cljest so that tests work - Consolidate workflow files for simplicity --- .github/workflows/cljest-tests.yml | 37 ------------------------------ .github/workflows/tests.yml | 30 ++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 39 deletions(-) delete mode 100644 .github/workflows/cljest-tests.yml diff --git a/.github/workflows/cljest-tests.yml b/.github/workflows/cljest-tests.yml deleted file mode 100644 index 82e6417..0000000 --- a/.github/workflows/cljest-tests.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: Run cljest tests - -on: - push: - branches: - - master - pull_request: - workflow_dispatch: - -concurrency: - group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' - cancel-in-progress: true - -jobs: - build: - runs-on: ubuntu-latest - defaults: - run: - working-directory: cljest - - steps: - - uses: actions/checkout@v3 - - name: Setup java - uses: actions/setup-java@v3 - with: - distribution: 'corretto' - java-version: '17' - - name: Setup Clojure - uses: DeLaGuardo/setup-clojure@9.5 - with: - cli: 1.11.1.1224 - - name: Install npm dependencies - run: npm install - - name: Build Jest code - run: clojure -X cljest.compilation/compile - - name: Run cljest tests - run: npm run jest:ci diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 69730ec..688e713 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,4 +1,4 @@ -name: "jest-preset-cljest: Lint and run tests" +name: Lint and tests on: push: @@ -12,7 +12,33 @@ concurrency: cancel-in-progress: true jobs: - lint-and-test: + cljest-tests: + runs-on: ubuntu-latest + defaults: + run: + working-directory: cljest + + steps: + - uses: actions/checkout@v3 + - name: Setup java + uses: actions/setup-java@v3 + with: + distribution: 'corretto' + java-version: '17' + - name: Setup Clojure + uses: DeLaGuardo/setup-clojure@9.5 + with: + cli: 1.11.1.1224 + - name: Link jest-preset-cljest + run: npm link ../jest-preset-cljest + - name: Install npm dependencies + run: npm install + - name: Build Jest code + run: clojure -X cljest.compilation/compile + - name: Run cljest tests + run: npm run jest:ci + + jest-preset-cljest-tests: runs-on: ubuntu-latest defaults: run: