@elliemae/pui-cli 9.0.0-next.64 → 9.0.0-next.65

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.
@@ -72,7 +72,36 @@ const cmdArgs = {
72
72
  maxWorkers: {
73
73
  string: true,
74
74
  default: "50%"
75
+ },
76
+ // example usage: pui-cli test --filterFnFilePath=./myFilter.js
77
+ // /\ this exports a filtering function as per documentation
78
+ // the filtering will be applied to the test that were already matched by the config file
79
+ filterFnFilePath: {
80
+ alias: "fffp",
81
+ string: true,
82
+ description: `Path to a module exporting a filtering function.
83
+ This asynchronous function receives a list of test paths which can be manipulated to exclude tests from running and must
84
+ return an object with shape { filtered: Array<string> } containing the tests that should be run by Jest. https://jestjs.io/docs/cli#--filterfile`
85
+ },
86
+ // ********************************************************************************************************
87
+ // The official website documentation says "testPathPatterns" as "plural",
88
+ // but the actual CLI working flag is "testPathPattern" as "singular"
89
+ // ********************************************************************************************************
90
+ // example usage: pui-cli test --testPathPattern=button
91
+ // /\ this will run against all test that regExp match the button string
92
+ // which funny enough means it will run all tests that have the word "button" in their path
93
+ // (e.g. "src/components/button/button.test.js")
94
+ testPathPattern: {
95
+ alias: "tpp",
96
+ string: true,
97
+ description: "A regexp pattern string that is matched against all tests paths before executing the test, https://jestjs.io/docs/cli#--testpathpatternsregex"
75
98
  }
99
+ /* the above two methods are compatible with the config file
100
+ testGlobs won't work because
101
+ ● Validation Error:
102
+ Configuration options testMatch and testRegex cannot be used together.
103
+ Configuration Documentation: https://jestjs.io/docs/configuration
104
+ */
76
105
  };
77
106
  const getJestFlags = (argv) => {
78
107
  const flagsArray = [
@@ -97,6 +126,10 @@ const getJestFlags = (argv) => {
97
126
  if (argv.passWithNoTests) flagsArray.push("--passWithNoTests");
98
127
  if (argv.findReleatedTests) flagsArray.push("--bail --findRelatedTests");
99
128
  if (argv.silent) flagsArray.push("--silent");
129
+ if (argv.filterFnFilePath)
130
+ flagsArray.push(`--filter=${argv.filterFnFilePath}`);
131
+ if (argv.testPathPattern)
132
+ flagsArray.push(`--testPathPattern=${argv.testPathPattern}`);
100
133
  if (isCi) flagsArray.push("--ci --no-colors");
101
134
  return flagsArray.join(" ");
102
135
  };
@@ -109,7 +142,7 @@ const debugTest = async () => {
109
142
  `node --inspect-brk ./node_modules/jest-cli/bin/jest.js --runInBand --watch`
110
143
  );
111
144
  };
112
- const testCmd = {
145
+ const typedTestCmd = {
113
146
  handler: async (argv) => {
114
147
  try {
115
148
  if ((0, import_utils.getCIEnv)()) {
@@ -129,4 +162,9 @@ const testCmd = {
129
162
  command: "test [options]",
130
163
  describe: "unit tests application code",
131
164
  builder: (yargsRef) => yargsRef.options(cmdArgs).help()
165
+ // the way yargs types are defined this fails if we don't cast it explicitly
166
+ // this cast is safe, we are not overriding the builder
167
+ // just telling typescript that our implementation is compatible with the yargs type system
168
+ // still leveraging the yargs types checks
132
169
  };
170
+ const testCmd = typedTestCmd;
@@ -83,7 +83,7 @@ const jestConfig = {
83
83
  '^.+\\.[jt]sx?$': ['@swc/jest', swcrcConfig],
84
84
  },
85
85
  transformIgnorePatterns: [
86
- // eslint-disable-next-line prettier/prettier, no-useless-escape
86
+ // eslint-disable-next-line no-useless-escape
87
87
  '/node_modules/(?!(\@elliemae\/pui-cli|lodash-es|react-select|react-dates|d3|internmap|delaunator|robust-predicates))/',
88
88
  ],
89
89
  globals: {
@@ -1,5 +1,5 @@
1
1
  import yargs from "yargs";
2
- import { exec, logError, logSuccess, getCIEnv } from "./utils.js";
2
+ import { exec, getCIEnv, logError, logSuccess } from "./utils.js";
3
3
  const cmdArgs = {
4
4
  fix: {
5
5
  boolean: true,
@@ -39,7 +39,36 @@ const cmdArgs = {
39
39
  maxWorkers: {
40
40
  string: true,
41
41
  default: "50%"
42
+ },
43
+ // example usage: pui-cli test --filterFnFilePath=./myFilter.js
44
+ // /\ this exports a filtering function as per documentation
45
+ // the filtering will be applied to the test that were already matched by the config file
46
+ filterFnFilePath: {
47
+ alias: "fffp",
48
+ string: true,
49
+ description: `Path to a module exporting a filtering function.
50
+ This asynchronous function receives a list of test paths which can be manipulated to exclude tests from running and must
51
+ return an object with shape { filtered: Array<string> } containing the tests that should be run by Jest. https://jestjs.io/docs/cli#--filterfile`
52
+ },
53
+ // ********************************************************************************************************
54
+ // The official website documentation says "testPathPatterns" as "plural",
55
+ // but the actual CLI working flag is "testPathPattern" as "singular"
56
+ // ********************************************************************************************************
57
+ // example usage: pui-cli test --testPathPattern=button
58
+ // /\ this will run against all test that regExp match the button string
59
+ // which funny enough means it will run all tests that have the word "button" in their path
60
+ // (e.g. "src/components/button/button.test.js")
61
+ testPathPattern: {
62
+ alias: "tpp",
63
+ string: true,
64
+ description: "A regexp pattern string that is matched against all tests paths before executing the test, https://jestjs.io/docs/cli#--testpathpatternsregex"
42
65
  }
66
+ /* the above two methods are compatible with the config file
67
+ testGlobs won't work because
68
+ ● Validation Error:
69
+ Configuration options testMatch and testRegex cannot be used together.
70
+ Configuration Documentation: https://jestjs.io/docs/configuration
71
+ */
43
72
  };
44
73
  const getJestFlags = (argv) => {
45
74
  const flagsArray = [
@@ -64,6 +93,10 @@ const getJestFlags = (argv) => {
64
93
  if (argv.passWithNoTests) flagsArray.push("--passWithNoTests");
65
94
  if (argv.findReleatedTests) flagsArray.push("--bail --findRelatedTests");
66
95
  if (argv.silent) flagsArray.push("--silent");
96
+ if (argv.filterFnFilePath)
97
+ flagsArray.push(`--filter=${argv.filterFnFilePath}`);
98
+ if (argv.testPathPattern)
99
+ flagsArray.push(`--testPathPattern=${argv.testPathPattern}`);
67
100
  if (isCi) flagsArray.push("--ci --no-colors");
68
101
  return flagsArray.join(" ");
69
102
  };
@@ -76,7 +109,7 @@ const debugTest = async () => {
76
109
  `node --inspect-brk ./node_modules/jest-cli/bin/jest.js --runInBand --watch`
77
110
  );
78
111
  };
79
- const testCmd = {
112
+ const typedTestCmd = {
80
113
  handler: async (argv) => {
81
114
  try {
82
115
  if (getCIEnv()) {
@@ -96,7 +129,12 @@ const testCmd = {
96
129
  command: "test [options]",
97
130
  describe: "unit tests application code",
98
131
  builder: (yargsRef) => yargsRef.options(cmdArgs).help()
132
+ // the way yargs types are defined this fails if we don't cast it explicitly
133
+ // this cast is safe, we are not overriding the builder
134
+ // just telling typescript that our implementation is compatible with the yargs type system
135
+ // still leveraging the yargs types checks
99
136
  };
137
+ const testCmd = typedTestCmd;
100
138
  export {
101
139
  testCmd
102
140
  };
@@ -83,7 +83,7 @@ const jestConfig = {
83
83
  '^.+\\.[jt]sx?$': ['@swc/jest', swcrcConfig],
84
84
  },
85
85
  transformIgnorePatterns: [
86
- // eslint-disable-next-line prettier/prettier, no-useless-escape
86
+ // eslint-disable-next-line no-useless-escape
87
87
  '/node_modules/(?!(\@elliemae\/pui-cli|lodash-es|react-select|react-dates|d3|internmap|delaunator|robust-predicates))/',
88
88
  ],
89
89
  globals: {
@@ -1,14 +1,3 @@
1
- import { CommandModule } from 'yargs';
2
- interface Arguments {
3
- fix: boolean;
4
- watch: boolean;
5
- debug: boolean;
6
- passWithNoTests: boolean;
7
- findReleatedTests: boolean;
8
- silent: boolean;
9
- coverage: string;
10
- maxWorkers: string;
11
- }
12
- export declare const testCmd: CommandModule<Record<string, never>, Arguments>;
13
- export {};
1
+ import type { CommandModule } from 'yargs';
2
+ export declare const testCmd: CommandModule;
14
3
  //# sourceMappingURL=test.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../../../../lib/commands/test.ts"],"names":[],"mappings":"AACA,OAAc,EAAQ,aAAa,EAAE,MAAM,OAAO,CAAC;AAEnD,UAAU,SAAS;IACjB,GAAG,EAAE,OAAO,CAAC;IACb,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;IACf,eAAe,EAAE,OAAO,CAAC;IACzB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB;AA6FD,eAAO,MAAM,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,SAAS,CAoBnE,CAAC"}
1
+ {"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../../../../lib/commands/test.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAIV,aAAa,EAEd,MAAM,OAAO,CAAC;AA4Kf,eAAO,MAAM,OAAO,EAAmB,aAAa,CAAC"}