apify-test-tools 0.5.7-beta.4 → 0.5.7-beta.6

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.
Files changed (96) hide show
  1. package/.github/workflows/_check_code.yaml +17 -18
  2. package/.husky/pre-commit +13 -0
  3. package/CHANGELOG.md +4 -2
  4. package/CONTRIBUTING.md +5 -0
  5. package/README.md +39 -43
  6. package/bin/build.ts +138 -87
  7. package/bin/diff-changes.ts +52 -23
  8. package/bin/diff-json-schema.ts +10 -3
  9. package/bin/git.ts +31 -9
  10. package/bin/github.ts +7 -6
  11. package/bin/main.ts +14 -8
  12. package/bin/slack.ts +6 -2
  13. package/bin/test-report.ts +55 -44
  14. package/bin/types.ts +56 -59
  15. package/bin/utils.ts +17 -12
  16. package/dist/bin/build.d.ts +1 -1
  17. package/dist/bin/build.d.ts.map +1 -1
  18. package/dist/bin/build.js +49 -31
  19. package/dist/bin/build.js.map +1 -1
  20. package/dist/bin/diff-changes.d.ts +1 -1
  21. package/dist/bin/diff-changes.d.ts.map +1 -1
  22. package/dist/bin/diff-changes.js +15 -3
  23. package/dist/bin/diff-changes.js.map +1 -1
  24. package/dist/bin/diff-json-schema.d.ts.map +1 -1
  25. package/dist/bin/diff-json-schema.js +6 -1
  26. package/dist/bin/diff-json-schema.js.map +1 -1
  27. package/dist/bin/git.d.ts +7 -2
  28. package/dist/bin/git.d.ts.map +1 -1
  29. package/dist/bin/git.js +23 -6
  30. package/dist/bin/git.js.map +1 -1
  31. package/dist/bin/github.d.ts +1 -3
  32. package/dist/bin/github.d.ts.map +1 -1
  33. package/dist/bin/github.js +5 -5
  34. package/dist/bin/github.js.map +1 -1
  35. package/dist/bin/main.js +7 -1
  36. package/dist/bin/main.js.map +1 -1
  37. package/dist/bin/slack.d.ts +1 -1
  38. package/dist/bin/slack.d.ts.map +1 -1
  39. package/dist/bin/slack.js +1 -1
  40. package/dist/bin/slack.js.map +1 -1
  41. package/dist/bin/test-report.d.ts.map +1 -1
  42. package/dist/bin/test-report.js +9 -3
  43. package/dist/bin/test-report.js.map +1 -1
  44. package/dist/bin/types.d.ts +0 -1
  45. package/dist/bin/types.d.ts.map +1 -1
  46. package/dist/bin/utils.d.ts.map +1 -1
  47. package/dist/bin/utils.js +11 -7
  48. package/dist/bin/utils.js.map +1 -1
  49. package/dist/lib/extend-expect.d.ts.map +1 -1
  50. package/dist/lib/extend-expect.js +11 -11
  51. package/dist/lib/extend-expect.js.map +1 -1
  52. package/dist/lib/lib.d.ts +3 -2
  53. package/dist/lib/lib.d.ts.map +1 -1
  54. package/dist/lib/lib.js +7 -3
  55. package/dist/lib/lib.js.map +1 -1
  56. package/dist/lib/run-test-result.d.ts +1 -1
  57. package/dist/lib/run-test-result.d.ts.map +1 -1
  58. package/dist/lib/run-test-result.js.map +1 -1
  59. package/dist/lib/types.d.ts +2 -3
  60. package/dist/lib/types.d.ts.map +1 -1
  61. package/dist/lib/utils.d.ts +1 -1
  62. package/dist/lib/utils.d.ts.map +1 -1
  63. package/dist/lib/utils.js +4 -1
  64. package/dist/lib/utils.js.map +1 -1
  65. package/dist/test/unit/bin/diff-changes.test.js +14 -7
  66. package/dist/test/unit/bin/diff-changes.test.js.map +1 -1
  67. package/dist/test/unit/bin/diff.test.js +14 -4
  68. package/dist/test/unit/bin/diff.test.js.map +1 -1
  69. package/dist/test/unit/bin/git.test.js +48 -19
  70. package/dist/test/unit/bin/git.test.js.map +1 -1
  71. package/dist/test/unit/custom-matchers.test.js +3 -8
  72. package/dist/test/unit/custom-matchers.test.js.map +1 -1
  73. package/dist/test/unit/should-built-and-test.test.js +75 -18
  74. package/dist/test/unit/should-built-and-test.test.js.map +1 -1
  75. package/dist/tsconfig.tsbuildinfo +1 -1
  76. package/eslint.config.mjs +4 -2
  77. package/knip.json +1 -1
  78. package/lib/extend-expect.ts +21 -21
  79. package/lib/lib.ts +17 -17
  80. package/lib/run-test-result.ts +6 -2
  81. package/lib/types.ts +5 -8
  82. package/lib/utils.ts +13 -9
  83. package/package.json +10 -3
  84. package/test/tsconfig.json +2 -4
  85. package/test/unit/bin/diff-changes.test.ts +14 -7
  86. package/test/unit/bin/diff.test.ts +19 -21
  87. package/test/unit/bin/git.test.ts +59 -20
  88. package/test/unit/custom-matchers.test.ts +10 -9
  89. package/test/unit/should-built-and-test.test.ts +77 -20
  90. package/bin/consts.ts +0 -6
  91. package/dist/bin/consts.d.ts +0 -4
  92. package/dist/bin/consts.d.ts.map +0 -1
  93. package/dist/bin/consts.js +0 -6
  94. package/dist/bin/consts.js.map +0 -1
  95. package/example-github-events/pull-request.json +0 -523
  96. package/example-github-events/push.json +0 -216
@@ -1,7 +1,8 @@
1
- import process from 'process';
2
- import { describe } from 'vitest';
1
+ import process from 'node:process';
3
2
 
4
3
  import { ApifyClient } from 'apify-client';
4
+ import { describe } from 'vitest';
5
+
5
6
  import { testStandbyActor, testTestActor } from '../../lib/lib.js';
6
7
  import { RunTestResult } from '../../lib/run-test-result.js';
7
8
 
@@ -11,13 +12,13 @@ enum PpeEventEnum {
11
12
  SEARCH_PAGE_SCRAPED = 'search-page-scraped',
12
13
  ADS_SCRAPED = 'ads-scraped',
13
14
  }
14
- const PPE_EVENT_CONST = {
15
- ACTOR_START: 'actor-start',
16
- ITEM_PUSHED: 'search-page-scraped',
17
- ADS_SCRAPED: 'ads-scraped',
18
- } as const;
15
+ type PPE_EVENT_CONST = {
16
+ ACTOR_START: 'actor-start';
17
+ ITEM_PUSHED: 'search-page-scraped';
18
+ ADS_SCRAPED: 'ads-scraped';
19
+ };
19
20
 
20
- // TODO: Remake these tests. k5MNKmaDGHlABDn2I run doesn't exist and we probably don't want to depend on fixed run
21
+ // TODO: Remake these tests. k5MNKmaDGHlABDn2I run doesn't exist and we probably don't want to depend on fixed run
21
22
  describe.skip('custom-matchers', { timeout: 100_000 }, () => {
22
23
  testTestActor('basic', async ({ expect }) => {
23
24
  const apifyClient = new ApifyClient({ token: process.env.TESTER_APIFY_TOKEN });
@@ -43,7 +44,7 @@ describe.skip('custom-matchers', { timeout: 100_000 }, () => {
43
44
  },
44
45
  });
45
46
 
46
- await expect(runResult).toFinishWith<(typeof PPE_EVENT_CONST)[keyof typeof PPE_EVENT_CONST]>({
47
+ await expect(runResult).toFinishWith<PPE_EVENT_CONST[keyof PPE_EVENT_CONST]>({
47
48
  datasetItemCount: { min: 1, max: 20 },
48
49
  chargedEventCounts: {
49
50
  'actor-start': 1,
@@ -40,7 +40,12 @@ describe('Should build and test parser', () => {
40
40
  test('Ignores dev-only readme', () => {
41
41
  const FILES = ['README.md', 'code/README.md', 'shared/README.md'];
42
42
 
43
- const actorsChanged = getChangedActors({ actorConfigs: ACTOR_CONFIGS, isLatest: false, filepathsChanged: FILES, commits });
43
+ const actorsChanged = getChangedActors({
44
+ actorConfigs: ACTOR_CONFIGS,
45
+ isLatest: false,
46
+ filepathsChanged: FILES,
47
+ commits,
48
+ });
44
49
 
45
50
  expect(actorsChanged).toEqual([]);
46
51
  });
@@ -48,7 +53,12 @@ describe('Should build and test parser', () => {
48
53
  test('Ignores other ignored files and folders', () => {
49
54
  const FILES = ['.vscode/', '.gitignore', '.husky/', '.eslintrc', '.editorconfig', '.actor/'];
50
55
 
51
- const actorsChanged = getChangedActors({ actorConfigs: ACTOR_CONFIGS, isLatest: false, filepathsChanged: FILES, commits });
56
+ const actorsChanged = getChangedActors({
57
+ actorConfigs: ACTOR_CONFIGS,
58
+ isLatest: false,
59
+ filepathsChanged: FILES,
60
+ commits,
61
+ });
52
62
 
53
63
  expect(actorsChanged).toEqual([]);
54
64
  });
@@ -56,7 +66,12 @@ describe('Should build and test parser', () => {
56
66
  test('Only builds latest for all Actors', () => {
57
67
  const FILES = ['shared/CHANGELOG.md', 'CHANGELOG.md'];
58
68
 
59
- const actorsChanged = getChangedActors({ actorConfigs: ACTOR_CONFIGS, isLatest: true, filepathsChanged: FILES, commits });
69
+ const actorsChanged = getChangedActors({
70
+ actorConfigs: ACTOR_CONFIGS,
71
+ isLatest: true,
72
+ filepathsChanged: FILES,
73
+ commits,
74
+ });
60
75
 
61
76
  expect(actorsChanged).toEqual(ACTOR_CONFIGS.filter(({ isStandalone }) => !isStandalone));
62
77
  });
@@ -64,26 +79,42 @@ describe('Should build and test parser', () => {
64
79
  test('Code updated, tests miniactors', () => {
65
80
  const FILES = ['code/src/main.ts', 'package.json'];
66
81
 
67
- const actorsChanged = getChangedActors({ actorConfigs: ACTOR_CONFIGS, isLatest: false, filepathsChanged: FILES, commits });
82
+ const actorsChanged = getChangedActors({
83
+ actorConfigs: ACTOR_CONFIGS,
84
+ isLatest: false,
85
+ filepathsChanged: FILES,
86
+ commits,
87
+ });
68
88
 
69
89
  expect(actorsChanged).toEqual(ACTOR_CONFIGS.filter(({ isStandalone }) => !isStandalone));
70
90
  });
71
91
 
72
92
  test('Specific Actor functionality configs updated', () => {
73
- const FILES = ['actors/lukaskrivka_testing-github-integration-1/.actor/actor.json', 'standalone-actors/lukaskrivka_test-standalone/Dockerfile'];
93
+ const FILES = [
94
+ 'actors/lukaskrivka_testing-github-integration-1/.actor/actor.json',
95
+ 'standalone-actors/lukaskrivka_test-standalone/Dockerfile',
96
+ ];
74
97
  // Default mock returns false = functional change
75
98
 
76
- const actorsChanged = getChangedActors({ actorConfigs: ACTOR_CONFIGS, isLatest: false, filepathsChanged: FILES, commits });
99
+ const actorsChanged = getChangedActors({
100
+ actorConfigs: ACTOR_CONFIGS,
101
+ isLatest: false,
102
+ filepathsChanged: FILES,
103
+ commits,
104
+ });
77
105
 
78
106
  expect(actorsChanged).toEqual([ACTOR_CONFIGS[0], ACTOR_CONFIGS[2]]);
79
107
  });
80
108
 
81
109
  test('src/main.ts updated', () => {
82
- const FILES = [
83
- 'src/main.ts',
84
- ];
110
+ const FILES = ['src/main.ts'];
85
111
 
86
- const actorsChanged = getChangedActors({ actorConfigs: ACTOR_CONFIGS, isLatest: true, filepathsChanged: FILES, commits });
112
+ const actorsChanged = getChangedActors({
113
+ actorConfigs: ACTOR_CONFIGS,
114
+ isLatest: true,
115
+ filepathsChanged: FILES,
116
+ commits,
117
+ });
87
118
 
88
119
  expect(actorsChanged).toEqual(ACTOR_CONFIGS.slice(0, 2));
89
120
  });
@@ -96,15 +127,28 @@ describe('Should build and test parser', () => {
96
127
  ];
97
128
  // Default mock returns false = functional change for the JSON file
98
129
 
99
- const actorsChanged = getChangedActors({ actorConfigs: ACTOR_CONFIGS, isLatest: false, filepathsChanged: FILES, commits });
130
+ const actorsChanged = getChangedActors({
131
+ actorConfigs: ACTOR_CONFIGS,
132
+ isLatest: false,
133
+ filepathsChanged: FILES,
134
+ commits,
135
+ });
100
136
 
101
137
  expect(actorsChanged).toEqual(ACTOR_CONFIGS);
102
138
  });
103
139
 
104
140
  test('Specific Actor non-functional configs updated', () => {
105
- const FILES = ['actors/lukaskrivka_testing-github-integration-2/.actor/README.md', 'standalone-actors/lukaskrivka_test-standalone/CHANGELOG.md'];
141
+ const FILES = [
142
+ 'actors/lukaskrivka_testing-github-integration-2/.actor/README.md',
143
+ 'standalone-actors/lukaskrivka_test-standalone/CHANGELOG.md',
144
+ ];
106
145
 
107
- const actorsChanged = getChangedActors({ actorConfigs: ACTOR_CONFIGS, isLatest: false, filepathsChanged: FILES, commits });
146
+ const actorsChanged = getChangedActors({
147
+ actorConfigs: ACTOR_CONFIGS,
148
+ isLatest: false,
149
+ filepathsChanged: FILES,
150
+ commits,
151
+ });
108
152
 
109
153
  expect(actorsChanged).toEqual([]);
110
154
  });
@@ -157,8 +201,8 @@ describe('Should build and test parser', () => {
157
201
  'actors/lukaskrivka_testing-github-integration-2/.actor/input_schema.json',
158
202
  ];
159
203
  // Actor 1 JSON is cosmetic-only, actor 2 JSON is functional
160
- isCosmeticOnlyJsonSchemaSpy.mockImplementation((_commits, filepath: string) =>
161
- !filepath.includes('input_schema.json'),
204
+ isCosmeticOnlyJsonSchemaSpy.mockImplementation(
205
+ (_commits, filepath: string) => !filepath.includes('input_schema.json'),
162
206
  );
163
207
 
164
208
  const actorsChanged = getChangedActors({
@@ -187,10 +231,20 @@ describe('Should build and test parser', () => {
187
231
  });
188
232
 
189
233
  test('Google Maps real user-case that had undefined', () => {
190
- const FILES = ['actors/compass_Google-Maps-Reviews-Scraper/.actor/INPUT_SCHEMA.json', 'actors/compass_crawler-google-places/.actor/INPUT_SCHEMA.json',
191
- 'code/src/consts.ts', 'code/src/crawlers/cheerio/routes.ts', 'code/src/detail_page_handle.ts', 'code/src/enqueue_places.ts',
192
- 'code/src/helper-classes/initialize-all.ts', 'code/src/helper-classes/stats.ts', 'code/src/helper-classes/unmatched-categories.ts',
193
- 'code/src/main.ts', 'code/src/typedefs/general.ts', 'code/src/utils/background-enqueue.ts'];
234
+ const FILES = [
235
+ 'actors/compass_Google-Maps-Reviews-Scraper/.actor/INPUT_SCHEMA.json',
236
+ 'actors/compass_crawler-google-places/.actor/INPUT_SCHEMA.json',
237
+ 'code/src/consts.ts',
238
+ 'code/src/crawlers/cheerio/routes.ts',
239
+ 'code/src/detail_page_handle.ts',
240
+ 'code/src/enqueue_places.ts',
241
+ 'code/src/helper-classes/initialize-all.ts',
242
+ 'code/src/helper-classes/stats.ts',
243
+ 'code/src/helper-classes/unmatched-categories.ts',
244
+ 'code/src/main.ts',
245
+ 'code/src/typedefs/general.ts',
246
+ 'code/src/utils/background-enqueue.ts',
247
+ ];
194
248
 
195
249
  const ACTOR_CONFIGS_GOOGLE_MAPS: ActorConfig[] = [
196
250
  {
@@ -242,7 +296,10 @@ describe('Should build and test parser', () => {
242
296
  ];
243
297
 
244
298
  const actorsChanged = getChangedActors({
245
- actorConfigs: ACTOR_CONFIGS_GOOGLE_MAPS, isLatest: false, filepathsChanged: FILES, commits,
299
+ actorConfigs: ACTOR_CONFIGS_GOOGLE_MAPS,
300
+ isLatest: false,
301
+ filepathsChanged: FILES,
302
+ commits,
246
303
  });
247
304
 
248
305
  expect(actorsChanged).toEqual(ACTOR_CONFIGS_GOOGLE_MAPS.filter(({ isStandalone }) => !isStandalone));
package/bin/consts.ts DELETED
@@ -1,6 +0,0 @@
1
- // Technically, upgrades in shared or packages might not need impact every actor
2
- // but we cannot really know that
3
- export const DEFAULT_BUILD_ALL_FOLDERS = ['code', 'shared', 'packages'];
4
-
5
- export const PERSISTED_GH_JOBS_KVS_ID = 'XIBdO8EJePdD0KiAI';
6
- export const MINIACTORS_LIST_STORE_ID = 'ftXklt2f2mN30Oc3y';
@@ -1,4 +0,0 @@
1
- export declare const DEFAULT_BUILD_ALL_FOLDERS: string[];
2
- export declare const PERSISTED_GH_JOBS_KVS_ID = "XIBdO8EJePdD0KiAI";
3
- export declare const MINIACTORS_LIST_STORE_ID = "ftXklt2f2mN30Oc3y";
4
- //# sourceMappingURL=consts.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../../bin/consts.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,yBAAyB,UAAiC,CAAC;AAExE,eAAO,MAAM,wBAAwB,sBAAsB,CAAC;AAC5D,eAAO,MAAM,wBAAwB,sBAAsB,CAAC"}
@@ -1,6 +0,0 @@
1
- // Technically, upgrades in shared or packages might not need impact every actor
2
- // but we cannot really know that
3
- export const DEFAULT_BUILD_ALL_FOLDERS = ['code', 'shared', 'packages'];
4
- export const PERSISTED_GH_JOBS_KVS_ID = 'XIBdO8EJePdD0KiAI';
5
- export const MINIACTORS_LIST_STORE_ID = 'ftXklt2f2mN30Oc3y';
6
- //# sourceMappingURL=consts.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"consts.js","sourceRoot":"","sources":["../../bin/consts.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,iCAAiC;AACjC,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;AAExE,MAAM,CAAC,MAAM,wBAAwB,GAAG,mBAAmB,CAAC;AAC5D,MAAM,CAAC,MAAM,wBAAwB,GAAG,mBAAmB,CAAC"}