xcratch-create 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xcratch-create",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Support tool to create new extension for Xcratch",
5
5
  "type": "module",
6
6
  "bin": {
@@ -0,0 +1,11 @@
1
+ module.exports = {
2
+ testEnvironment: 'node',
3
+ transform: {
4
+ '^.+\\.jsx?$': 'babel-jest'
5
+ },
6
+ setupFilesAfterEnv: ['./test/setup-test.js'],
7
+ moduleNameMapper: {
8
+ '\\.(png|jpg|jpeg|gif|svg)$': '<rootDir>/test/mocks/fileMock.js'
9
+ },
10
+ testMatch: ['**/test/unit/**/*.test.js'],
11
+ };
@@ -6,7 +6,7 @@
6
6
  "setup-dev": "node ./scripts/setup-dev.mjs",
7
7
  "build": "rollup -c ./scripts/rollup.config.mjs",
8
8
  "watch": "rollup -c ./scripts/rollup.config.mjs --watch",
9
- "test": "mocha"
9
+ "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
10
10
  },
11
11
  "devDependencies": {
12
12
  "@babel/core": "^7.26.9",
@@ -22,14 +22,14 @@
22
22
  "@rollup/plugin-json": "^6.1.0",
23
23
  "@rollup/plugin-multi-entry": "^6.0.1",
24
24
  "@rollup/plugin-node-resolve": "^16.0.0",
25
- "chai": "^5.2.0",
26
25
  "core-js": "^3.40.0",
27
26
  "eslint": "^8.57.0",
28
27
  "eslint-config-scratch": "^9.0.9",
29
28
  "eslint-plugin-import": "^2.31.0",
30
- "eslint-plugin-mocha": "^10.5.0",
29
+ "eslint-plugin-jest": "^27.6.3",
31
30
  "fs-extra": "^11.3.0",
32
- "mocha": "^11.1.0",
31
+ "jest": "^29.7.0",
32
+ "jest-environment-jsdom": "^29.7.0",
33
33
  "rollup": "^4.34.7",
34
34
  "rollup-plugin-polyfill-node": "^0.13.0"
35
35
  }
@@ -1,7 +1,6 @@
1
1
  import BlockType from '../../extension-support/block-type';
2
2
  import ArgumentType from '../../extension-support/argument-type';
3
3
  import Cast from '../../util/cast';
4
- import log from '../../util/log';
5
4
  import translations from './translations.json';
6
5
  import blockIcon from './block-icon.png';
7
6
 
@@ -138,7 +137,7 @@ class ExtensionBlocks {
138
137
  doIt (args) {
139
138
  const statement = Cast.toString(args.SCRIPT);
140
139
  const func = new Function(`return (${statement})`);
141
- log.log(`doIt: ${statement}`);
140
+ console.log(`doIt: ${statement}`);
142
141
  return func.call(this);
143
142
  }
144
143
  }
@@ -1,11 +1,11 @@
1
1
  module.exports = {
2
2
  root: true,
3
- plugins: ["mocha"],
4
- extends: ["plugin:mocha/recommended"],
3
+ plugins: ["jest"],
4
+ extends: ["plugin:jest/recommended"],
5
5
  env: {
6
6
  browser: true,
7
7
  es6: true,
8
- mocha: true,
8
+ "jest/globals": true,
9
9
  },
10
10
  parserOptions: {
11
11
  sourceType: "module",
@@ -0,0 +1 @@
1
+ module.exports = 'test-file-stub';
@@ -1,4 +1,2 @@
1
- require.extensions[".png"] = function () {
2
- return null;
3
- };
4
-
1
+ // Jest automatically handles require extensions through moduleNameMapper in jest.config.js
2
+ // This file is still used for any additional test setup
@@ -1,5 +1,3 @@
1
- import { describe, it } from "mocha";
2
- import { expect } from "chai";
3
1
  import { blockClass } from "../../src/vm/extensions/block/index.js";
4
2
 
5
3
  describe("blockClass", () => {
@@ -9,14 +7,14 @@ describe("blockClass", () => {
9
7
  }
10
8
  };
11
9
 
12
- it("should create an instance of blockClass", () => {
10
+ test("should create an instance of blockClass", () => {
13
11
  const block = new blockClass(runtime);
14
- expect(block).to.be.an.instanceOf(blockClass);
12
+ expect(block).toBeInstanceOf(blockClass);
15
13
  });
16
14
 
17
- it("doIt('3 + 4') should return 7", () => {
15
+ test("doIt('3 + 4') should return 7", () => {
18
16
  const block = new blockClass(runtime);
19
17
  const result = block.doIt({SCRIPT: "3 + 4"});
20
- expect(result).to.equal(7);
18
+ expect(result).toBe(7);
21
19
  });
22
20
  });
@@ -1,4 +0,0 @@
1
- module.exports = {
2
- require: ["@babel/register", "./test/setup-test.js"],
3
- spec: "test/unit/**/*.test.js",
4
- };