diff --git a/CHANGELOG.md b/CHANGELOG.md index 8cbb35a..c4482ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,8 @@ and adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ### 🔧 Internal changes - Added a changelog and pull request template. +- Modified `roughjs` import to be compatible with Jest's `moduleNameMapper` config option. +- Added instructions on the `memory-viz/README.md` for running the test suite. ## [0.1.0] - 2024-04-16 diff --git a/demo/webpack.common.js b/demo/webpack.common.js index 65a43ba..ace98fe 100644 --- a/demo/webpack.common.js +++ b/demo/webpack.common.js @@ -44,7 +44,7 @@ module.exports = { resolve: { extensions: [".ts", ".tsx", ".js", ".jsx", ".json", ".css"], alias: { - "memory-viz": path.resolve(__dirname, "../memory-viz/src"), + "memory-viz": path.resolve(__dirname, "../memory-viz"), }, }, }; diff --git a/demo/webpack.dev.js b/demo/webpack.dev.js index 5e61be1..654d6d0 100644 --- a/demo/webpack.dev.js +++ b/demo/webpack.dev.js @@ -1,4 +1,5 @@ const { merge } = require("webpack-merge"); +const path = require("path"); const common = require("./webpack.common.js"); module.exports = merge(common, { diff --git a/jest.config.ts b/jest.config.ts index 41aefd5..10c0532 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -103,7 +103,7 @@ const config: Config = { // preset: undefined, // Run tests from one or more projects - projects: ["./demo/jest.config.ts", "./memory-viz/src/jest.config.ts"], + projects: ["./demo/jest.config.ts", "./memory-viz/jest.config.ts"], // Use this configuration option to add custom reporters to Jest // reporters: undefined, diff --git a/memory-viz/README.md b/memory-viz/README.md index 4e10e37..319ea0b 100644 --- a/memory-viz/README.md +++ b/memory-viz/README.md @@ -50,6 +50,14 @@ This will use `webpack` to watch for changes to the Javascript source files and _Note_: this command will keep running until you manually terminate it (Ctrl + C), and so you'll need to open a new terminal window to enter new terminal commands like running the demo below. +### Running tests + +To run the test suite, execute the following command: + +```console +$ npm run test --workspace=memory-viz +``` + ## Usage The only function that a user will ever have to call is `user_functions.draw`. diff --git a/memory-viz/src/jest.config.ts b/memory-viz/jest.config.ts similarity index 100% rename from memory-viz/src/jest.config.ts rename to memory-viz/jest.config.ts diff --git a/memory-viz/src/memory_model.ts b/memory-viz/src/memory_model.ts index bb01069..9524f5c 100644 --- a/memory-viz/src/memory_model.ts +++ b/memory-viz/src/memory_model.ts @@ -1,4 +1,4 @@ -import rough from "roughjs/bundled/rough.esm.js"; +import rough from "roughjs"; import merge from "deepmerge"; @@ -75,7 +75,7 @@ export class MemoryModel { this.svg.setAttribute("width", options.width || 800); this.svg.setAttribute("height", options.height || 800); this.seed = options.seed || 0; - this.rough_svg = rough.svg(this.svg, { seed: this.seed }); + this.rough_svg = rough.svg(this.svg, { options: { seed: this.seed } }); // The user must not directly use this constructor; their only interaction should be with 'user_functions.draw'. for (const key in config) { diff --git a/memory-viz/webpack.common.js b/memory-viz/webpack.common.js index e320ccc..8835661 100644 --- a/memory-viz/webpack.common.js +++ b/memory-viz/webpack.common.js @@ -36,5 +36,8 @@ module.exports = { }, resolve: { extensions: [".ts", ".js"], + alias: { + roughjs: "roughjs/bundled/rough.esm.js", + }, }, };