jasmine-focused-test-detector 1.0.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.
@@ -0,0 +1,12 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="WEB_MODULE" version="4">
3
+ <component name="NewModuleRootManager">
4
+ <content url="file://$MODULE_DIR$">
5
+ <excludeFolder url="file://$MODULE_DIR$/.tmp" />
6
+ <excludeFolder url="file://$MODULE_DIR$/temp" />
7
+ <excludeFolder url="file://$MODULE_DIR$/tmp" />
8
+ </content>
9
+ <orderEntry type="inheritedJdk" />
10
+ <orderEntry type="sourceFolder" forTests="false" />
11
+ </component>
12
+ </module>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/focus test detector.iml" filepath="$PROJECT_DIR$/.idea/focus test detector.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
package/index.js ADDED
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/env node
2
+ import fs from 'fs';
3
+ import path from 'path';
4
+ import { fileURLToPath } from 'url';
5
+ import { parse } from '@typescript-eslint/parser';
6
+ import globby from 'globby';
7
+ import yargs from 'yargs';
8
+ import { hideBin } from 'yargs/helpers';
9
+
10
+ const __filename = fileURLToPath(import.meta.url);
11
+ const __dirname = path.dirname(__filename);
12
+
13
+ const argv = yargs(hideBin(process.argv))
14
+ .option('files', {
15
+ alias: 'f',
16
+ type: 'string',
17
+ description: 'Comma-separated list of files or glob patterns to check',
18
+ demandOption: true
19
+ })
20
+ .help()
21
+ .argv;
22
+
23
+ const filePatterns = argv.files.split(',').map(f => f.trim());
24
+
25
+ (async () => {
26
+ const files = await globby(filePatterns);
27
+
28
+ if (files.length === 0) {
29
+ console.log('No files matched the given patterns.');
30
+ process.exit(0);
31
+ }
32
+
33
+ let found = false;
34
+ const focusedFiles = [];
35
+
36
+ function visit(node, filePath) {
37
+ if (
38
+ node.type === 'CallExpression' &&
39
+ node.callee.type === 'Identifier' &&
40
+ (node.callee.name === 'fit' || node.callee.name === 'fdescribe')
41
+ ) {
42
+ found = true;
43
+ if (!focusedFiles.includes(filePath)) focusedFiles.push(filePath);
44
+ }
45
+ for (const key in node) {
46
+ if (node[key] && typeof node[key] === 'object') {
47
+ visit(node[key], filePath);
48
+ }
49
+ }
50
+ }
51
+
52
+ for (const filePath of files) {
53
+ const code = fs.readFileSync(filePath, 'utf8');
54
+ let ast;
55
+ try {
56
+ ast = parse(code, { sourceType: 'module', ecmaVersion: 2020 });
57
+ } catch (err) {
58
+ console.warn(`Warning: Failed to parse ${filePath}: ${err.message}`);
59
+ continue;
60
+ }
61
+ visit(ast, filePath);
62
+ }
63
+
64
+ if (found) {
65
+ console.error('\n==========================================');
66
+ console.error('BUILD FAILED: Found focused tests (fit/fdescribe)');
67
+ console.error('==========================================');
68
+ focusedFiles.forEach(f => console.error(`ERROR: Focused test found in ${f}`));
69
+ console.error('Please remove all fit/fdescribe calls before committing.\n');
70
+ process.exit(1);
71
+ }
72
+
73
+ console.log('✓ No focused tests found');
74
+ process.exit(0);
75
+ })();
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "jasmine-focused-test-detector",
3
+ "version": "1.0.0",
4
+ "description": "Detect focused tests (fit/fdescribe) in Jasmine test files",
5
+ "main": "index.js",
6
+ "type": "module",
7
+ "bin": {
8
+ "jasmine-focused-test-detector": "index.js"
9
+ },
10
+ "scripts": {
11
+ "start": "node index.js",
12
+ "test": "node index.js --help"
13
+ },
14
+ "author": "Pouya Sadat Alhosseini",
15
+ "license": "MIT",
16
+ "dependencies": {
17
+ "@typescript-eslint/parser": "^6.2.0",
18
+ "globby": "^14.1.0",
19
+ "yargs": "^17.7.2"
20
+ },
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/Pouya2781/jasmine-focused-test-detector.git"
24
+ },
25
+ "keywords": [
26
+ "angular",
27
+ "frontend",
28
+ "jasmine",
29
+ "test",
30
+ "cli"
31
+ ]
32
+ }