fragment-ts 1.0.18 → 1.0.20

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.
@@ -50,6 +50,7 @@ class TestCommand {
50
50
  .option("--env <environment>", "Environment mode: dev (use src/) or prod (use dist/)", "auto")
51
51
  .option("--pattern <pattern>", "Test file pattern", "**/*.spec.ts")
52
52
  .option("--coverage", "Generate coverage report")
53
+ .option("--no-color", "Disable colored output")
53
54
  .action(async (options) => {
54
55
  await this.runTests(options);
55
56
  });
@@ -81,7 +82,7 @@ class TestCommand {
81
82
  useTypeScript = false;
82
83
  mode = "production (dist/)";
83
84
  basePath = "dist";
84
- pattern = options.pattern.replace(".ts", ".js") || "**/*.spec.js";
85
+ pattern = options.pattern.replace(/\.ts$/, ".js") || "**/*.spec.js";
85
86
  }
86
87
  else {
87
88
  // Auto-detect
@@ -95,191 +96,54 @@ class TestCommand {
95
96
  useTypeScript = false;
96
97
  mode = "auto-detected production (dist/)";
97
98
  basePath = "dist";
98
- pattern = options.pattern.replace(".ts", ".js") || "**/*.spec.js";
99
+ pattern = options.pattern.replace(/\.ts$/, ".js") || "**/*.spec.js";
99
100
  }
100
101
  else {
101
102
  console.log(chalk_1.default.red("No src/ or dist/ directory found. Run: fragment init"));
102
103
  return;
103
104
  }
104
105
  }
105
- console.log(chalk_1.default.gray(` Mode: ${mode}\n`));
106
- const scriptContent = `
107
- ${useTypeScript ? "require('ts-node/register/transpile-only');" : ""}
108
- require('reflect-metadata');
109
-
110
- const { glob } = require('glob');
111
- const path = require('path');
112
-
113
- // Global test state
114
- const testState = {
115
- suites: [],
116
- currentSuite: null,
117
- passed: 0,
118
- failed: 0,
119
- errors: []
120
- };
121
-
122
- // Global test functions
123
- global.describe = function(name, fn) {
124
- const suite = { name, tests: [] };
125
- testState.suites.push(suite);
126
- testState.currentSuite = suite;
127
- fn();
128
- testState.currentSuite = null;
129
- };
130
-
131
- global.it = function(name, fn) {
132
- if (!testState.currentSuite) {
133
- throw new Error('it() must be called inside describe()');
134
- }
135
- testState.currentSuite.tests.push({ name, fn });
136
- };
137
-
138
- global.expect = function(actual) {
139
- return {
140
- toBe(expected) {
141
- if (actual !== expected) {
142
- throw new Error(\`Expected \${actual} to be \${expected}\`);
143
- }
144
- },
145
- toEqual(expected) {
146
- if (JSON.stringify(actual) !== JSON.stringify(expected)) {
147
- throw new Error(\`Expected \${JSON.stringify(actual)} to equal \${JSON.stringify(expected)}\`);
148
- }
149
- },
150
- toBeTruthy() {
151
- if (!actual) {
152
- throw new Error(\`Expected \${actual} to be truthy\`);
153
- }
154
- },
155
- toBeFalsy() {
156
- if (actual) {
157
- throw new Error(\`Expected \${actual} to be falsy\`);
158
- }
159
- },
160
- toThrow(expectedError) {
161
- let threw = false;
162
- let error = null;
163
- try {
164
- actual();
165
- } catch (e) {
166
- threw = true;
167
- error = e;
168
- }
169
- if (!threw) {
170
- throw new Error('Expected function to throw');
171
- }
172
- if (expectedError && error.message !== expectedError) {
173
- throw new Error(\`Expected error message "\${expectedError}" but got "\${error.message}"\`);
174
- }
175
- },
176
- toBeInstanceOf(expected) {
177
- if (!(actual instanceof expected)) {
178
- throw new Error(\`Expected \${actual} to be instance of \${expected.name}\`);
179
- }
180
- },
181
- toContain(expected) {
182
- if (!actual.includes(expected)) {
183
- throw new Error(\`Expected \${actual} to contain \${expected}\`);
184
- }
185
- },
186
- toHaveProperty(property, value) {
187
- if (!(property in actual)) {
188
- throw new Error(\`Expected object to have property \${property}\`);
189
- }
190
- if (value !== undefined && actual[property] !== value) {
191
- throw new Error(\`Expected property \${property} to be \${value} but got \${actual[property]}\`);
192
- }
193
- },
194
- toBeNull() {
195
- if (actual !== null) {
196
- throw new Error(\`Expected \${actual} to be null\`);
197
- }
198
- },
199
- toBeUndefined() {
200
- if (actual !== undefined) {
201
- throw new Error(\`Expected \${actual} to be undefined\`);
202
- }
203
- },
204
- toHaveLength(expected) {
205
- if (actual.length !== expected) {
206
- throw new Error(\`Expected length \${expected} but got \${actual.length}\`);
207
- }
208
- }
209
- };
210
- };
211
-
212
- async function runTests() {
213
- try {
214
- // Find and load test files
215
- const files = await glob('${basePath}/${pattern}', { cwd: process.cwd() });
216
-
217
- if (files.length === 0) {
218
- console.log('No test files found matching pattern: ${basePath}/${pattern}');
219
- process.exit(0);
220
- }
221
-
222
- console.log(\`Found \${files.length} test file(s)\\n\`);
223
-
224
- // Load all test files
225
- for (const file of files) {
226
- require(path.resolve(file));
227
- }
228
-
229
- // Run all tests
230
- for (const suite of testState.suites) {
231
- console.log(\`\\n📦 \${suite.name}\`);
232
-
233
- for (const test of suite.tests) {
234
- try {
235
- await test.fn();
236
- console.log(\` ✓ \${test.name}\`);
237
- testState.passed++;
238
- } catch (error) {
239
- console.log(\` ✗ \${test.name}\`);
240
- console.error(\` \${error.message}\`);
241
- testState.failed++;
242
- testState.errors.push({
243
- suite: suite.name,
244
- test: test.name,
245
- error: error.message,
246
- stack: error.stack
247
- });
248
- }
249
- }
250
- }
251
-
252
- // Print summary
253
- console.log(\`\\n\\n📊 Results: \${testState.passed} passed, \${testState.failed} failed\\n\`);
254
-
255
- if (testState.failed > 0) {
256
- console.log('\\n❌ Failed Tests:\\n');
257
- testState.errors.forEach(err => {
258
- console.log(\` \${err.suite} > \${err.test}\`);
259
- console.log(\` \${err.error}\\n\`);
260
- });
261
- process.exit(1);
262
- } else {
263
- console.log('✅ All tests passed!\\n');
264
- process.exit(0);
265
- }
266
- } catch (error) {
267
- console.error('Error running tests:', error);
268
- process.exit(1);
269
- }
270
- }
271
-
272
- runTests();
273
- `;
106
+ console.log(chalk_1.default.gray(` Mode: ${mode}`));
107
+ console.log(chalk_1.default.gray(` Pattern: ${basePath}/${pattern}`));
108
+ // Check if we need to use ts-node for TypeScript files
109
+ const tsConfigPath = path.join(cwd, "tsconfig.json");
110
+ const hasTsConfig = fs.existsSync(tsConfigPath);
111
+ // Create a simple runner script that uses our test runner module
112
+ const scriptContent = this.generateRunnerScript({
113
+ useTypeScript,
114
+ basePath,
115
+ pattern,
116
+ hasTsConfig,
117
+ tsConfigPath,
118
+ watchMode: options.watch,
119
+ coverage: options.coverage,
120
+ noColor: options.color === false,
121
+ });
274
122
  const scriptPath = path.join(cwd, ".fragment-test-runner.js");
275
123
  try {
276
124
  fs.writeFileSync(scriptPath, scriptContent);
125
+ // Make the script executable
126
+ fs.chmodSync(scriptPath, "755");
277
127
  const nodeArgs = [scriptPath];
278
128
  const env = {
279
129
  ...process.env,
280
130
  TS_NODE_TRANSPILE_ONLY: "true",
281
131
  NODE_ENV: "test",
132
+ // Only set TS_NODE_PROJECT if tsconfig exists
133
+ ...(hasTsConfig && useTypeScript
134
+ ? { TS_NODE_PROJECT: tsConfigPath }
135
+ : {}),
136
+ // Handle color output
137
+ FORCE_COLOR: options.color === false ? "0" : "1",
282
138
  };
139
+ // Add --watch support
140
+ if (options.watch) {
141
+ console.log(chalk_1.default.yellow("\n⚠️ Watch mode is not yet implemented. Running once.\n"));
142
+ }
143
+ // Add --coverage support
144
+ if (options.coverage) {
145
+ console.log(chalk_1.default.yellow("\n⚠️ Coverage reporting is not yet implemented.\n"));
146
+ }
283
147
  const proc = (0, child_process_1.spawn)("node", nodeArgs, {
284
148
  cwd,
285
149
  stdio: "inherit",
@@ -289,7 +153,9 @@ runTests();
289
153
  try {
290
154
  fs.unlinkSync(scriptPath);
291
155
  }
292
- catch { }
156
+ catch (e) {
157
+ // Ignore cleanup errors
158
+ }
293
159
  process.exit(code || 0);
294
160
  });
295
161
  proc.on("error", (error) => {
@@ -297,7 +163,9 @@ runTests();
297
163
  try {
298
164
  fs.unlinkSync(scriptPath);
299
165
  }
300
- catch { }
166
+ catch (e) {
167
+ // Ignore cleanup errors
168
+ }
301
169
  process.exit(1);
302
170
  });
303
171
  }
@@ -306,6 +174,114 @@ runTests();
306
174
  process.exit(1);
307
175
  }
308
176
  }
177
+ static generateRunnerScript(options) {
178
+ const { useTypeScript, basePath, pattern, hasTsConfig, tsConfigPath, noColor, } = options;
179
+ // Determine the runner path - try to find the actual test runner
180
+ // This assumes the test runner is installed as a dependency
181
+ let runnerImportPath = "fragment-ts/testing";
182
+ // Try to find the local test runner first for development
183
+ const possiblePaths = [
184
+ path.join(process.cwd(), "node_modules", "fragment-ts", "testing"),
185
+ path.join(process.cwd(), "node_modules", "fragment-ts", "dist", "testing"),
186
+ path.join(__dirname, "..", "..", "testing"), // If we're in the fragment-ts package itself
187
+ ];
188
+ let resolvedRunnerPath = runnerImportPath;
189
+ for (const testPath of possiblePaths) {
190
+ if (fs.existsSync(testPath + ".ts") || fs.existsSync(testPath + ".js")) {
191
+ resolvedRunnerPath = testPath;
192
+ break;
193
+ }
194
+ }
195
+ return `
196
+ "use strict";
197
+
198
+ ${useTypeScript ? "require('ts-node/register/transpile-only');" : ""}
199
+ require('reflect-metadata');
200
+
201
+ // Set environment
202
+ process.env.NODE_ENV = 'test';
203
+ ${noColor ? "process.env.FORCE_COLOR = '0';" : "process.env.FORCE_COLOR = '1';"}
204
+
205
+ // Set up TypeScript config if available
206
+ ${hasTsConfig && useTypeScript
207
+ ? `
208
+ try {
209
+ const tsNode = require('ts-node');
210
+ tsNode.register({
211
+ project: '${tsConfigPath}',
212
+ transpileOnly: true,
213
+ compilerOptions: {
214
+ module: 'commonjs',
215
+ target: 'ES2020',
216
+ esModuleInterop: true,
217
+ skipLibCheck: true
218
+ }
219
+ });
220
+ } catch (error) {
221
+ // Ignore, ts-node might not be available
222
+ }`
223
+ : ""}
224
+
225
+ let testRunner;
226
+ try {
227
+ // Try to import the test runner
228
+ const testModule = require('${resolvedRunnerPath}');
229
+
230
+ // Handle different export patterns
231
+ if (testModule.getTestRunner) {
232
+ testRunner = testModule.getTestRunner();
233
+ } else if (testModule.TestRunner) {
234
+ testRunner = new testModule.TestRunner();
235
+ } else if (testModule.default && testModule.default.getTestRunner) {
236
+ testRunner = testModule.default.getTestRunner();
237
+ } else {
238
+ // Fallback to creating a new instance
239
+ testRunner = testModule;
240
+ }
241
+ } catch (error) {
242
+ console.error('Failed to load test runner:', error.message);
243
+ console.error('Make sure fragment-ts is installed as a dependency');
244
+ process.exit(1);
245
+ }
246
+
247
+ async function runTests() {
248
+ try {
249
+ console.log('Looking for test files...');
250
+
251
+ // Load test files with the runner
252
+ await testRunner.loadTestFiles('${basePath}/${pattern}');
253
+
254
+ // Run tests
255
+ await testRunner.run();
256
+ } catch (error) {
257
+ console.error('\\n❌ Error running tests:', error.message);
258
+
259
+ if (error.stack && process.env.DEBUG) {
260
+ console.error(error.stack);
261
+ }
262
+
263
+ process.exit(1);
264
+ }
265
+ }
266
+
267
+ // Handle process termination
268
+ process.on('SIGINT', () => {
269
+ console.log('\\n\\nTest run interrupted');
270
+ process.exit(130);
271
+ });
272
+
273
+ process.on('SIGTERM', () => {
274
+ console.log('\\n\\nTest run terminated');
275
+ process.exit(143);
276
+ });
277
+
278
+ // Run the tests
279
+ runTests().catch(error => {
280
+ console.error('Unhandled error:', error);
281
+ process.exit(1);
282
+ });
283
+ `;
284
+ }
309
285
  }
310
286
  exports.TestCommand = TestCommand;
311
287
  //# sourceMappingURL=test.command.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"test.command.js","sourceRoot":"","sources":["../../../src/cli/commands/test.command.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,kDAA0B;AAC1B,2CAA6B;AAC7B,iDAAsC;AACtC,uCAAyB;AAEzB,MAAa,WAAW;IACtB,MAAM,CAAC,QAAQ,CAAC,OAAgB;QAC9B,OAAO;aACJ,OAAO,CAAC,MAAM,CAAC;aACf,WAAW,CAAC,WAAW,CAAC;aACxB,MAAM,CAAC,SAAS,EAAE,yBAAyB,CAAC;aAC5C,MAAM,CACL,qBAAqB,EACrB,sDAAsD,EACtD,MAAM,CACP;aACA,MAAM,CAAC,qBAAqB,EAAE,mBAAmB,EAAE,cAAc,CAAC;aAClE,MAAM,CAAC,YAAY,EAAE,0BAA0B,CAAC;aAChD,MAAM,CAAC,KA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,IAAI,aAAa;YAC1B,CAAC,CAAC;;;;gBAIU,YAAY;;;;;;;;;;;EAW1B;YACE,CAAC,CAAC,EACN;;;;;gCAKgC,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;sCAwBZ,QAAQ,IAAI,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+BxD,CAAC;IACA,CAAC;CACF;AAzSD,kCAySC"}
@@ -1,6 +1,8 @@
1
1
  export interface TestSuite {
2
2
  name: string;
3
3
  tests: Test[];
4
+ beforeEachHooks: Array<() => void | Promise<void>>;
5
+ afterEachHooks: Array<() => void | Promise<void>>;
4
6
  }
5
7
  export interface Test {
6
8
  name: string;
@@ -10,17 +12,28 @@ export declare class TestRunner {
10
12
  private suites;
11
13
  private passed;
12
14
  private failed;
15
+ private errors;
13
16
  describe(name: string, fn: () => void): void;
14
17
  run(): Promise<void>;
15
18
  loadTestFiles(pattern: string): Promise<void>;
16
19
  }
20
+ export declare function getTestRunner(): TestRunner;
21
+ export declare function initTestRunner(): TestRunner;
17
22
  export declare function describe(name: string, fn: () => void): void;
18
23
  export declare function it(name: string, fn: () => void | Promise<void>): void;
24
+ export declare function beforeEach(fn: () => void | Promise<void>): void;
25
+ export declare function afterEach(fn: () => void | Promise<void>): void;
19
26
  export declare function expect(actual: any): {
20
27
  toBe(expected: any): void;
21
28
  toEqual(expected: any): void;
22
29
  toBeTruthy(): void;
23
30
  toBeFalsy(): void;
24
- toThrow(): void;
31
+ toThrow(expectedError?: string): void;
32
+ toBeInstanceOf(expected: any): void;
33
+ toContain(expected: any): void;
34
+ toHaveProperty(property: string, value?: any): void;
35
+ toBeNull(): void;
36
+ toBeUndefined(): void;
37
+ toHaveLength(expected: number): void;
25
38
  };
26
39
  //# sourceMappingURL=runner.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/testing/runner.ts"],"names":[],"mappings":"AAiBA,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,M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