movehat 0.0.8-alpha.0 → 0.0.9-alpha.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/dist/cli.js CHANGED
@@ -4,6 +4,7 @@ import { readFileSync } from 'fs';
4
4
  import { fileURLToPath } from 'url';
5
5
  import { dirname, join } from 'path';
6
6
  import testCommand from './commands/test.js';
7
+ import testMoveCommand from './commands/test-move.js';
7
8
  import compileCommand from './commands/compile.js';
8
9
  import initCommand from './commands/init.js';
9
10
  import runCommand from './commands/run.js';
@@ -59,8 +60,23 @@ program
59
60
  .action(runCommand);
60
61
  program
61
62
  .command('test')
62
- .description('Run TypeScript tests with Mocha')
63
- .action(testCommand);
63
+ .description('Run all tests (Move + TypeScript)')
64
+ .option('--move-only', 'Run only Move unit tests')
65
+ .option('--ts-only', 'Run only TypeScript integration tests')
66
+ .option('--watch', 'Run TypeScript tests in watch mode')
67
+ .option('--filter <pattern>', 'Filter Move tests by name pattern')
68
+ .action((options) => testCommand(options));
69
+ program
70
+ .command('test:move')
71
+ .description('Run Move unit tests')
72
+ .option('--filter <pattern>', 'Filter tests by name pattern')
73
+ .option('--ignore-warnings', 'Ignore compilation warnings')
74
+ .action((options) => testMoveCommand(options));
75
+ program
76
+ .command('test:ts')
77
+ .description('Run TypeScript integration tests')
78
+ .option('--watch', 'Run tests in watch mode')
79
+ .action((options) => testCommand({ tsOnly: true, watch: options.watch }));
64
80
  // Fork commands
65
81
  const fork = program
66
82
  .command('fork')
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,IAAI,EA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,cAAc,CAAC,uBAAuB,EAAE,eAAe,CAAC;KACxD,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC,CAAC;AAE3D,IAAI;KACC,OAAO,CAAC,MAAM,CAAC;KACf,WAAW,CAAC,6BAA6B,CAAC;KAC1C,MAAM,CAAC,mBAAmB,EAAE,kBAAkB,CAAC;KAC/C,cAAc,CAAC,yBAAyB,EAAE,iBAAiB,CAAC;KAC5D,cAAc,CAAC,mBAAmB,EAAE,gBAAgB,CAAC;KACrD,MAAM,CAAC,oBAAoB,EAAE,WAAW,EAAE,4BAA4B,CAAC;KACvE,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC;AAEnD,IAAI;KACC,OAAO,CAAC,MAAM,CAAC;KACf,WAAW,CAAC,0BAA0B,CAAC;KACvC,MAAM,CAAC,GAAG,EAAE,CAAC,eAAe,EAAE,CAAC,CAAC;AAErC,IAAI;KACC,OAAO,CAAC,OAAO,CAAC;KAChB,WAAW,CAAC,2CAA2C,CAAC;KACxD,MAAM,CAAC,mBAAmB,EAAE,kBAAkB,CAAC;KAC/C,MAAM,CAAC,mBAAmB,EAAE,mCAAmC,EAAE,SAAS,EAAE,IAAI,CAAC;KACjF,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC;AAEpD,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ interface TestMoveOptions {
2
+ filter?: string;
3
+ ignoreWarnings?: boolean;
4
+ }
5
+ export default function testMoveCommand(options?: TestMoveOptions): Promise<void>;
6
+ export {};
7
+ //# sourceMappingURL=test-move.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-move.d.ts","sourceRoot":"","sources":["../../src/commands/test-move.ts"],"names":[],"mappings":"AAKA,UAAU,eAAe;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,wBAA8B,eAAe,CAAC,OAAO,GAAE,eAAoB,iBAkD1E"}
@@ -0,0 +1,50 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { spawn } from "child_process";
4
+ import { loadUserConfig } from "../core/config.js";
5
+ export default async function testMoveCommand(options = {}) {
6
+ try {
7
+ const userConfig = await loadUserConfig();
8
+ const moveDir = path.resolve(process.cwd(), userConfig.moveDir || "./move");
9
+ if (!fs.existsSync(moveDir)) {
10
+ console.error(`Move directory not found: ${moveDir}`);
11
+ console.error(` Update movehat.config.ts -> moveDir`);
12
+ process.exit(1);
13
+ }
14
+ console.log("Running Move unit tests...\n");
15
+ const args = ["move", "test", "--package-dir", moveDir];
16
+ // Add filter if provided
17
+ if (options.filter) {
18
+ args.push("--filter", options.filter);
19
+ }
20
+ // Add ignore-warnings flag if provided
21
+ if (options.ignoreWarnings) {
22
+ args.push("--ignore-compile-warnings");
23
+ }
24
+ // Spawn movement CLI
25
+ const child = spawn("movement", args, {
26
+ stdio: "inherit",
27
+ cwd: process.cwd(),
28
+ });
29
+ child.on("exit", (code) => {
30
+ if (code === 0) {
31
+ console.log("\n✓ Move tests passed");
32
+ }
33
+ else {
34
+ console.error("\n✗ Move tests failed");
35
+ }
36
+ process.exit(code || 0);
37
+ });
38
+ child.on("error", (error) => {
39
+ console.error(`Failed to run Move tests: ${error.message}`);
40
+ console.error(" Make sure Movement CLI is installed");
41
+ console.error(" Run: movement --version");
42
+ process.exit(1);
43
+ });
44
+ }
45
+ catch (err) {
46
+ console.error("Move tests failed:", err.message ?? err);
47
+ process.exit(1);
48
+ }
49
+ }
50
+ //# sourceMappingURL=test-move.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-move.js","sourceRoot":"","sources":["../../src/commands/test-move.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;A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IAAI,EAAE,EAAE;YACxB,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;gBACf,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;YACvC,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;YACzC,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC;QAC1B,CAAC,CAAC,CAAC;QAEH,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YAC1B,OAAO,CAAC,KAAK,CAAC,6BAA6B,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YAC5D,OAAO,CAAC,KAAK,CAAC,wCAAwC,CAAC,CAAC;YACxD,OAAO,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;YAC5C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,GAAQ,EAAE,CAAC;QAClB,OAAO,CAAC,KAAK,CAAC,oBAAoB,EAAE,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,CAAC;QACxD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
@@ -1,2 +1,9 @@
1
- export default function testCommand(): Promise<void>;
1
+ interface TestOptions {
2
+ moveOnly?: boolean;
3
+ tsOnly?: boolean;
4
+ watch?: boolean;
5
+ filter?: string;
6
+ }
7
+ export default function testCommand(options?: TestOptions): Promise<void>;
8
+ export {};
2
9
  //# sourceMappingURL=test.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../../src/commands/test.ts"],"names":[],"mappings":"AAIA,wBAA8B,WAAW,kBAqCxC"}
1
+ {"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../../src/commands/test.ts"],"names":[],"mappings":"AAMA,UAAU,WAAW;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAA8B,WAAW,CAAC,OAAO,GAAE,WAAgB,iBA2BlE"}
@@ -1,35 +1,116 @@
1
1
  import { spawn } from "child_process";
2
2
  import { join } from "path";
3
3
  import { existsSync } from "fs";
4
- export default async function testCommand() {
5
- const testDir = join(process.cwd(), "tests");
6
- if (!existsSync(testDir)) {
7
- console.error("No tests directory found.");
8
- console.error(" Create a 'tests' directory with your TypeScript test files.");
9
- process.exit(1);
4
+ import { loadUserConfig } from "../core/config.js";
5
+ import path from "path";
6
+ export default async function testCommand(options = {}) {
7
+ // Handle move-only flag
8
+ if (options.moveOnly) {
9
+ return runMoveTestsSync(options.filter);
10
+ }
11
+ // Handle ts-only flag (current behavior)
12
+ if (options.tsOnly) {
13
+ return runTypeScriptTests(options.watch);
10
14
  }
11
- console.log("Running TypeScript tests with Mocha...\n");
12
- // Find mocha from project's node_modules
13
- const mochaPath = join(process.cwd(), "node_modules", ".bin", "mocha");
14
- if (!existsSync(mochaPath)) {
15
- console.error("Mocha not found in project dependencies.");
16
- console.error(" Install it with: npm install --save-dev mocha");
15
+ // Default: Run both Move and TypeScript tests
16
+ console.log("Running all tests...\n");
17
+ console.log("=" + "=".repeat(60) + "\n");
18
+ // First run Move tests (fail fast)
19
+ try {
20
+ await runMoveTestsSync();
21
+ console.log("\n" + "=" + "=".repeat(60) + "\n");
22
+ }
23
+ catch (error) {
24
+ console.error("\n✗ Move tests failed");
25
+ console.log("\n" + "=" + "=".repeat(60));
17
26
  process.exit(1);
18
27
  }
19
- // Run mocha with TypeScript support
20
- const child = spawn(mochaPath, [], {
21
- stdio: "inherit",
22
- env: {
23
- ...process.env,
24
- // Inherit network if set
25
- },
26
- });
27
- child.on("exit", (code) => {
28
- process.exit(code || 0);
28
+ // Then run TypeScript tests
29
+ return runTypeScriptTests(false);
30
+ }
31
+ function runMoveTestsSync(filter) {
32
+ return new Promise(async (resolve, reject) => {
33
+ console.log("1. Move Unit Tests");
34
+ console.log("-" + "-".repeat(60) + "\n");
35
+ try {
36
+ const userConfig = await loadUserConfig();
37
+ const moveDir = path.resolve(process.cwd(), userConfig.moveDir || "./move");
38
+ if (!existsSync(moveDir)) {
39
+ console.log("⊘ No Move directory found (./move not found)");
40
+ console.log(" Skipping Move tests...\n");
41
+ resolve();
42
+ return;
43
+ }
44
+ const args = ["move", "test", "--package-dir", moveDir];
45
+ if (filter) {
46
+ args.push("--filter", filter);
47
+ }
48
+ const child = spawn("movement", args, {
49
+ stdio: "inherit",
50
+ cwd: process.cwd(),
51
+ });
52
+ child.on("exit", (code) => {
53
+ if (code === 0) {
54
+ console.log("\n✓ Move tests passed");
55
+ resolve();
56
+ }
57
+ else {
58
+ reject(new Error("Move tests failed"));
59
+ }
60
+ });
61
+ child.on("error", (error) => {
62
+ console.error(`Failed to run Move tests: ${error.message}`);
63
+ console.error(" Make sure Movement CLI is installed");
64
+ reject(error);
65
+ });
66
+ }
67
+ catch (error) {
68
+ reject(error);
69
+ }
29
70
  });
30
- child.on("error", (error) => {
31
- console.error(`Failed to run tests: ${error.message}`);
32
- process.exit(1);
71
+ }
72
+ function runTypeScriptTests(watch = false) {
73
+ return new Promise((resolve, reject) => {
74
+ console.log("2. TypeScript Integration Tests");
75
+ console.log("-" + "-".repeat(60) + "\n");
76
+ const testDir = join(process.cwd(), "tests");
77
+ if (!existsSync(testDir)) {
78
+ console.log("⊘ No TypeScript tests found (tests directory not found)");
79
+ console.log(" Skipping TypeScript tests...\n");
80
+ resolve();
81
+ return;
82
+ }
83
+ const mochaPath = join(process.cwd(), "node_modules", ".bin", "mocha");
84
+ if (!existsSync(mochaPath)) {
85
+ console.error("✗ Mocha not found in project dependencies.");
86
+ console.error(" Install it with: npm install --save-dev mocha");
87
+ reject(new Error("Mocha not found"));
88
+ return;
89
+ }
90
+ const args = watch ? ["--watch"] : [];
91
+ const child = spawn(mochaPath, args, {
92
+ stdio: "inherit",
93
+ env: {
94
+ ...process.env,
95
+ },
96
+ });
97
+ child.on("exit", (code) => {
98
+ if (code === 0) {
99
+ console.log("\n✓ TypeScript tests passed");
100
+ console.log("\n" + "=" + "=".repeat(60));
101
+ console.log("\n✓ All tests passed!\n");
102
+ resolve();
103
+ }
104
+ else {
105
+ console.error("\n✗ TypeScript tests failed");
106
+ console.log("\n" + "=" + "=".repeat(60));
107
+ process.exit(code || 1);
108
+ }
109
+ });
110
+ child.on("error", (error) => {
111
+ console.error(`Failed to run TypeScript tests: ${error.message}`);
112
+ reject(error);
113
+ });
33
114
  });
34
115
  }
35
116
  //# sourceMappingURL=test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"test.js","sourceRoot":"","sources":["../../src/commands/test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAEhC,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,WAAW;IACvC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,CAAC,CAAC;IAE7C,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QACzB,OAAO,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC;QAC3C,OAAO,CAAC,KAAK,CAAC,gEAAgE,CAAC,CAAC;QAChF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAC;IAExD,yCAAyC;IACzC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAEvE,IAAI,CAAC,UAAU,CA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AE;YACxB,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;gBACf,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;gBAC3C,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;gBACzC,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;gBACvC,OAAO,EAAE,CAAC;YACZ,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;gBAC7C,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;gBACzC,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YAC1B,OAAO,CAAC,KAAK,CAAC,mCAAmC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YAClE,MAAM,CAAC,KAAK,CAAC,CAAC;QAChB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -52,11 +52,25 @@ npm run compile
52
52
  npm test
53
53
  ```
54
54
 
55
- **How it works:**
56
- - Tests use **Transaction Simulation** - no real blockchain required
57
- - Runs instantly without gas costs
58
- - Uses Movement testnet by default with auto-generated test accounts
59
- - Perfect for TDD and CI/CD workflows
55
+ **Two types of tests available:**
56
+
57
+ 1. **Move Unit Tests** (`tests/Counter.move` lines 50-63)
58
+ - Written in Move with `#[test]` annotations
59
+ - Test internal logic and business rules
60
+ - Ultra-fast execution (milliseconds)
61
+ - Run with: `npm run test:move`
62
+
63
+ 2. **TypeScript Integration Tests** (`tests/Counter.test.ts`)
64
+ - Written in TypeScript using Transaction Simulation
65
+ - Test end-to-end flows and SDK integration
66
+ - No blockchain or gas costs required
67
+ - Run with: `npm run test:ts`
68
+
69
+ **Commands:**
70
+ - `npm test` - Runs both Move + TypeScript tests
71
+ - `npm run test:move` - Only Move unit tests (fast)
72
+ - `npm run test:ts` - Only TypeScript integration tests
73
+ - `npm run test:watch` - TypeScript tests in watch mode
60
74
 
61
75
  ### 5. Deploy (optional)
62
76
 
@@ -3,8 +3,10 @@
3
3
  "version": "1.0.0",
4
4
  "type": "module",
5
5
  "scripts": {
6
- "test": "mocha",
7
- "test:watch": "mocha --watch",
6
+ "test": "movehat test",
7
+ "test:move": "movehat test:move",
8
+ "test:ts": "movehat test:ts",
9
+ "test:watch": "movehat test:ts --watch",
8
10
  "deploy": "movehat run scripts/deploy-counter.ts"
9
11
  },
10
12
  "dependencies": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "movehat",
3
- "version": "0.0.8-alpha.0",
3
+ "version": "0.0.9-alpha.0",
4
4
  "type": "module",
5
5
  "description": "Hardhat-like development framework for Movement L1 and Aptos Move smart contracts",
6
6
  "bin": {
package/src/cli.ts CHANGED
@@ -4,6 +4,7 @@ import { readFileSync } from 'fs';
4
4
  import { fileURLToPath } from 'url';
5
5
  import { dirname, join } from 'path';
6
6
  import testCommand from './commands/test.js';
7
+ import testMoveCommand from './commands/test-move.js';
7
8
  import compileCommand from './commands/compile.js';
8
9
  import initCommand from './commands/init.js';
9
10
  import runCommand from './commands/run.js';
@@ -67,8 +68,25 @@ program
67
68
 
68
69
  program
69
70
  .command('test')
70
- .description('Run TypeScript tests with Mocha')
71
- .action(testCommand);
71
+ .description('Run all tests (Move + TypeScript)')
72
+ .option('--move-only', 'Run only Move unit tests')
73
+ .option('--ts-only', 'Run only TypeScript integration tests')
74
+ .option('--watch', 'Run TypeScript tests in watch mode')
75
+ .option('--filter <pattern>', 'Filter Move tests by name pattern')
76
+ .action((options) => testCommand(options));
77
+
78
+ program
79
+ .command('test:move')
80
+ .description('Run Move unit tests')
81
+ .option('--filter <pattern>', 'Filter tests by name pattern')
82
+ .option('--ignore-warnings', 'Ignore compilation warnings')
83
+ .action((options) => testMoveCommand(options));
84
+
85
+ program
86
+ .command('test:ts')
87
+ .description('Run TypeScript integration tests')
88
+ .option('--watch', 'Run tests in watch mode')
89
+ .action((options) => testCommand({ tsOnly: true, watch: options.watch }));
72
90
 
73
91
  // Fork commands
74
92
  const fork = program
@@ -0,0 +1,61 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { spawn } from "child_process";
4
+ import { loadUserConfig } from "../core/config.js";
5
+
6
+ interface TestMoveOptions {
7
+ filter?: string;
8
+ ignoreWarnings?: boolean;
9
+ }
10
+
11
+ export default async function testMoveCommand(options: TestMoveOptions = {}) {
12
+ try {
13
+ const userConfig = await loadUserConfig();
14
+ const moveDir = path.resolve(process.cwd(), userConfig.moveDir || "./move");
15
+
16
+ if (!fs.existsSync(moveDir)) {
17
+ console.error(`Move directory not found: ${moveDir}`);
18
+ console.error(` Update movehat.config.ts -> moveDir`);
19
+ process.exit(1);
20
+ }
21
+
22
+ console.log("Running Move unit tests...\n");
23
+
24
+ const args = ["move", "test", "--package-dir", moveDir];
25
+
26
+ // Add filter if provided
27
+ if (options.filter) {
28
+ args.push("--filter", options.filter);
29
+ }
30
+
31
+ // Add ignore-warnings flag if provided
32
+ if (options.ignoreWarnings) {
33
+ args.push("--ignore-compile-warnings");
34
+ }
35
+
36
+ // Spawn movement CLI
37
+ const child = spawn("movement", args, {
38
+ stdio: "inherit",
39
+ cwd: process.cwd(),
40
+ });
41
+
42
+ child.on("exit", (code) => {
43
+ if (code === 0) {
44
+ console.log("\n✓ Move tests passed");
45
+ } else {
46
+ console.error("\n✗ Move tests failed");
47
+ }
48
+ process.exit(code || 0);
49
+ });
50
+
51
+ child.on("error", (error) => {
52
+ console.error(`Failed to run Move tests: ${error.message}`);
53
+ console.error(" Make sure Movement CLI is installed");
54
+ console.error(" Run: movement --version");
55
+ process.exit(1);
56
+ });
57
+ } catch (err: any) {
58
+ console.error("Move tests failed:", err.message ?? err);
59
+ process.exit(1);
60
+ }
61
+ }
@@ -1,42 +1,140 @@
1
1
  import { spawn } from "child_process";
2
2
  import { join } from "path";
3
3
  import { existsSync } from "fs";
4
+ import { loadUserConfig } from "../core/config.js";
5
+ import path from "path";
4
6
 
5
- export default async function testCommand() {
6
- const testDir = join(process.cwd(), "tests");
7
+ interface TestOptions {
8
+ moveOnly?: boolean;
9
+ tsOnly?: boolean;
10
+ watch?: boolean;
11
+ filter?: string;
12
+ }
7
13
 
8
- if (!existsSync(testDir)) {
9
- console.error("No tests directory found.");
10
- console.error(" Create a 'tests' directory with your TypeScript test files.");
11
- process.exit(1);
14
+ export default async function testCommand(options: TestOptions = {}) {
15
+ // Handle move-only flag
16
+ if (options.moveOnly) {
17
+ return runMoveTestsSync(options.filter);
12
18
  }
13
19
 
14
- console.log("Running TypeScript tests with Mocha...\n");
20
+ // Handle ts-only flag (current behavior)
21
+ if (options.tsOnly) {
22
+ return runTypeScriptTests(options.watch);
23
+ }
15
24
 
16
- // Find mocha from project's node_modules
17
- const mochaPath = join(process.cwd(), "node_modules", ".bin", "mocha");
25
+ // Default: Run both Move and TypeScript tests
26
+ console.log("Running all tests...\n");
27
+ console.log("=" + "=".repeat(60) + "\n");
18
28
 
19
- if (!existsSync(mochaPath)) {
20
- console.error("Mocha not found in project dependencies.");
21
- console.error(" Install it with: npm install --save-dev mocha");
29
+ // First run Move tests (fail fast)
30
+ try {
31
+ await runMoveTestsSync();
32
+ console.log("\n" + "=" + "=".repeat(60) + "\n");
33
+ } catch (error) {
34
+ console.error("\n✗ Move tests failed");
35
+ console.log("\n" + "=" + "=".repeat(60));
22
36
  process.exit(1);
23
37
  }
24
38
 
25
- // Run mocha with TypeScript support
26
- const child = spawn(mochaPath, [], {
27
- stdio: "inherit",
28
- env: {
29
- ...process.env,
30
- // Inherit network if set
31
- },
32
- });
39
+ // Then run TypeScript tests
40
+ return runTypeScriptTests(false);
41
+ }
42
+
43
+ function runMoveTestsSync(filter?: string): Promise<void> {
44
+ return new Promise(async (resolve, reject) => {
45
+ console.log("1. Move Unit Tests");
46
+ console.log("-" + "-".repeat(60) + "\n");
47
+
48
+ try {
49
+ const userConfig = await loadUserConfig();
50
+ const moveDir = path.resolve(process.cwd(), userConfig.moveDir || "./move");
51
+
52
+ if (!existsSync(moveDir)) {
53
+ console.log("⊘ No Move directory found (./move not found)");
54
+ console.log(" Skipping Move tests...\n");
55
+ resolve();
56
+ return;
57
+ }
58
+
59
+ const args = ["move", "test", "--package-dir", moveDir];
60
+
61
+ if (filter) {
62
+ args.push("--filter", filter);
63
+ }
64
+
65
+ const child = spawn("movement", args, {
66
+ stdio: "inherit",
67
+ cwd: process.cwd(),
68
+ });
69
+
70
+ child.on("exit", (code) => {
71
+ if (code === 0) {
72
+ console.log("\n✓ Move tests passed");
73
+ resolve();
74
+ } else {
75
+ reject(new Error("Move tests failed"));
76
+ }
77
+ });
33
78
 
34
- child.on("exit", (code) => {
35
- process.exit(code || 0);
79
+ child.on("error", (error) => {
80
+ console.error(`Failed to run Move tests: ${error.message}`);
81
+ console.error(" Make sure Movement CLI is installed");
82
+ reject(error);
83
+ });
84
+ } catch (error) {
85
+ reject(error);
86
+ }
36
87
  });
88
+ }
37
89
 
38
- child.on("error", (error) => {
39
- console.error(`Failed to run tests: ${error.message}`);
40
- process.exit(1);
90
+ function runTypeScriptTests(watch: boolean = false): Promise<void> {
91
+ return new Promise((resolve, reject) => {
92
+ console.log("2. TypeScript Integration Tests");
93
+ console.log("-" + "-".repeat(60) + "\n");
94
+
95
+ const testDir = join(process.cwd(), "tests");
96
+
97
+ if (!existsSync(testDir)) {
98
+ console.log("⊘ No TypeScript tests found (tests directory not found)");
99
+ console.log(" Skipping TypeScript tests...\n");
100
+ resolve();
101
+ return;
102
+ }
103
+
104
+ const mochaPath = join(process.cwd(), "node_modules", ".bin", "mocha");
105
+
106
+ if (!existsSync(mochaPath)) {
107
+ console.error("✗ Mocha not found in project dependencies.");
108
+ console.error(" Install it with: npm install --save-dev mocha");
109
+ reject(new Error("Mocha not found"));
110
+ return;
111
+ }
112
+
113
+ const args = watch ? ["--watch"] : [];
114
+
115
+ const child = spawn(mochaPath, args, {
116
+ stdio: "inherit",
117
+ env: {
118
+ ...process.env,
119
+ },
120
+ });
121
+
122
+ child.on("exit", (code) => {
123
+ if (code === 0) {
124
+ console.log("\n✓ TypeScript tests passed");
125
+ console.log("\n" + "=" + "=".repeat(60));
126
+ console.log("\n✓ All tests passed!\n");
127
+ resolve();
128
+ } else {
129
+ console.error("\n✗ TypeScript tests failed");
130
+ console.log("\n" + "=" + "=".repeat(60));
131
+ process.exit(code || 1);
132
+ }
133
+ });
134
+
135
+ child.on("error", (error) => {
136
+ console.error(`Failed to run TypeScript tests: ${error.message}`);
137
+ reject(error);
138
+ });
41
139
  });
42
- }
140
+ }
@@ -52,11 +52,25 @@ npm run compile
52
52
  npm test
53
53
  ```
54
54
 
55
- **How it works:**
56
- - Tests use **Transaction Simulation** - no real blockchain required
57
- - Runs instantly without gas costs
58
- - Uses Movement testnet by default with auto-generated test accounts
59
- - Perfect for TDD and CI/CD workflows
55
+ **Two types of tests available:**
56
+
57
+ 1. **Move Unit Tests** (`tests/Counter.move` lines 50-63)
58
+ - Written in Move with `#[test]` annotations
59
+ - Test internal logic and business rules
60
+ - Ultra-fast execution (milliseconds)
61
+ - Run with: `npm run test:move`
62
+
63
+ 2. **TypeScript Integration Tests** (`tests/Counter.test.ts`)
64
+ - Written in TypeScript using Transaction Simulation
65
+ - Test end-to-end flows and SDK integration
66
+ - No blockchain or gas costs required
67
+ - Run with: `npm run test:ts`
68
+
69
+ **Commands:**
70
+ - `npm test` - Runs both Move + TypeScript tests
71
+ - `npm run test:move` - Only Move unit tests (fast)
72
+ - `npm run test:ts` - Only TypeScript integration tests
73
+ - `npm run test:watch` - TypeScript tests in watch mode
60
74
 
61
75
  ### 5. Deploy (optional)
62
76
 
@@ -3,8 +3,10 @@
3
3
  "version": "1.0.0",
4
4
  "type": "module",
5
5
  "scripts": {
6
- "test": "mocha",
7
- "test:watch": "mocha --watch",
6
+ "test": "movehat test",
7
+ "test:move": "movehat test:move",
8
+ "test:ts": "movehat test:ts",
9
+ "test:watch": "movehat test:ts --watch",
8
10
  "deploy": "movehat run scripts/deploy-counter.ts"
9
11
  },
10
12
  "dependencies": {