apify-test-tools 0.6.0 → 0.6.2-beta.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.
Files changed (108) hide show
  1. package/.github/workflows/_check_code.yaml +17 -19
  2. package/.github/workflows/_update_release_metadata.yaml +1 -1
  3. package/.github/workflows/manual_release_stable.yaml +1 -0
  4. package/.github/workflows/on_master.yaml +2 -0
  5. package/.husky/pre-commit +13 -0
  6. package/CHANGELOG.md +17 -3
  7. package/CONTRIBUTING.md +5 -0
  8. package/README.md +39 -43
  9. package/bin/build.ts +138 -87
  10. package/bin/diff-changes.ts +156 -0
  11. package/bin/diff-json-schema.ts +50 -0
  12. package/bin/git.ts +42 -11
  13. package/bin/github.ts +7 -6
  14. package/bin/main.ts +31 -13
  15. package/bin/slack.ts +6 -2
  16. package/bin/test-report.ts +55 -44
  17. package/bin/types.ts +56 -59
  18. package/bin/utils.ts +19 -131
  19. package/dist/bin/build.d.ts +1 -1
  20. package/dist/bin/build.d.ts.map +1 -1
  21. package/dist/bin/build.js +49 -31
  22. package/dist/bin/build.js.map +1 -1
  23. package/dist/bin/diff-changes.d.ts +16 -0
  24. package/dist/bin/diff-changes.d.ts.map +1 -0
  25. package/dist/bin/diff-changes.js +103 -0
  26. package/dist/bin/diff-changes.js.map +1 -0
  27. package/dist/bin/diff-json-schema.d.ts +7 -0
  28. package/dist/bin/diff-json-schema.d.ts.map +1 -0
  29. package/dist/bin/diff-json-schema.js +45 -0
  30. package/dist/bin/diff-json-schema.js.map +1 -0
  31. package/dist/bin/git.d.ts +8 -3
  32. package/dist/bin/git.d.ts.map +1 -1
  33. package/dist/bin/git.js +35 -10
  34. package/dist/bin/git.js.map +1 -1
  35. package/dist/bin/github.d.ts +1 -3
  36. package/dist/bin/github.d.ts.map +1 -1
  37. package/dist/bin/github.js +5 -5
  38. package/dist/bin/github.js.map +1 -1
  39. package/dist/bin/main.js +19 -7
  40. package/dist/bin/main.js.map +1 -1
  41. package/dist/bin/slack.d.ts +1 -1
  42. package/dist/bin/slack.d.ts.map +1 -1
  43. package/dist/bin/slack.js +1 -1
  44. package/dist/bin/slack.js.map +1 -1
  45. package/dist/bin/test-report.d.ts.map +1 -1
  46. package/dist/bin/test-report.js +9 -3
  47. package/dist/bin/test-report.js.map +1 -1
  48. package/dist/bin/types.d.ts +0 -1
  49. package/dist/bin/types.d.ts.map +1 -1
  50. package/dist/bin/utils.d.ts +0 -14
  51. package/dist/bin/utils.d.ts.map +1 -1
  52. package/dist/bin/utils.js +12 -95
  53. package/dist/bin/utils.js.map +1 -1
  54. package/dist/lib/extend-expect.d.ts.map +1 -1
  55. package/dist/lib/extend-expect.js +11 -11
  56. package/dist/lib/extend-expect.js.map +1 -1
  57. package/dist/lib/lib.d.ts +3 -2
  58. package/dist/lib/lib.d.ts.map +1 -1
  59. package/dist/lib/lib.js +7 -3
  60. package/dist/lib/lib.js.map +1 -1
  61. package/dist/lib/run-test-result.d.ts +1 -1
  62. package/dist/lib/run-test-result.d.ts.map +1 -1
  63. package/dist/lib/run-test-result.js.map +1 -1
  64. package/dist/lib/types.d.ts +2 -3
  65. package/dist/lib/types.d.ts.map +1 -1
  66. package/dist/lib/utils.d.ts +1 -1
  67. package/dist/lib/utils.d.ts.map +1 -1
  68. package/dist/lib/utils.js +4 -1
  69. package/dist/lib/utils.js.map +1 -1
  70. package/dist/test/unit/bin/diff-changes.test.d.ts +2 -0
  71. package/dist/test/unit/bin/diff-changes.test.d.ts.map +1 -0
  72. package/dist/test/unit/bin/diff-changes.test.js +159 -0
  73. package/dist/test/unit/bin/diff-changes.test.js.map +1 -0
  74. package/dist/test/unit/bin/diff.test.d.ts +2 -0
  75. package/dist/test/unit/bin/diff.test.d.ts.map +1 -0
  76. package/dist/test/unit/bin/diff.test.js +143 -0
  77. package/dist/test/unit/bin/diff.test.js.map +1 -0
  78. package/dist/test/unit/bin/git.test.js +48 -19
  79. package/dist/test/unit/bin/git.test.js.map +1 -1
  80. package/dist/test/unit/custom-matchers.test.js +3 -8
  81. package/dist/test/unit/custom-matchers.test.js.map +1 -1
  82. package/dist/test/unit/parse-commit.test.js +1 -1
  83. package/dist/test/unit/parse-commit.test.js.map +1 -1
  84. package/dist/test/unit/should-built-and-test.test.js +159 -39
  85. package/dist/test/unit/should-built-and-test.test.js.map +1 -1
  86. package/dist/tsconfig.tsbuildinfo +1 -1
  87. package/eslint.config.mjs +4 -2
  88. package/knip.json +1 -1
  89. package/lib/extend-expect.ts +21 -21
  90. package/lib/lib.ts +17 -17
  91. package/lib/run-test-result.ts +6 -2
  92. package/lib/types.ts +5 -8
  93. package/lib/utils.ts +13 -9
  94. package/package.json +61 -54
  95. package/test/tsconfig.json +2 -4
  96. package/test/unit/bin/diff-changes.test.ts +182 -0
  97. package/test/unit/bin/diff.test.ts +212 -0
  98. package/test/unit/bin/git.test.ts +59 -20
  99. package/test/unit/custom-matchers.test.ts +10 -9
  100. package/test/unit/parse-commit.test.ts +2 -1
  101. package/test/unit/should-built-and-test.test.ts +181 -40
  102. package/bin/consts.ts +0 -6
  103. package/dist/bin/consts.d.ts +0 -4
  104. package/dist/bin/consts.d.ts.map +0 -1
  105. package/dist/bin/consts.js +0 -6
  106. package/dist/bin/consts.js.map +0 -1
  107. package/example-github-events/pull-request.json +0 -523
  108. package/example-github-events/push.json +0 -216
@@ -0,0 +1,212 @@
1
+ import type { MockInstance } from 'vitest';
2
+ import { beforeEach, describe, expect, it, test, vi } from 'vitest';
3
+
4
+ import { isCosmeticOnlyJsonSchemaChange } from '../../../bin/diff-json-schema.js';
5
+ import * as Utils from '../../../bin/utils.js';
6
+
7
+ const commits = [
8
+ { sha: 'Commit1', author: '', date: '', message: '' },
9
+ { sha: 'Commit3', author: '', date: '', message: '' },
10
+ ];
11
+
12
+ describe('isCosmeticOnlyJsonSchemaChange', () => {
13
+ let gitCommandSpy: MockInstance;
14
+
15
+ beforeEach(() => {
16
+ gitCommandSpy = vi.spyOn(Utils, 'spawnCommandInGhWorkspace');
17
+ });
18
+
19
+ const mockGitCalls = (oldJson: string, newJson: string) => {
20
+ gitCommandSpy.mockReturnValueOnce(oldJson).mockReturnValueOnce(newJson);
21
+ };
22
+
23
+ test('returns true when nothing changed', () => {
24
+ const json = JSON.stringify({ type: 'string', title: 'My field' });
25
+ mockGitCalls(json, json);
26
+ expect(isCosmeticOnlyJsonSchemaChange(commits, 'actors/foo/actor.json')).toBe(true);
27
+ });
28
+
29
+ test('returns true when only title changes', () => {
30
+ mockGitCalls(
31
+ JSON.stringify({ type: 'string', title: 'Old title' }),
32
+ JSON.stringify({ type: 'string', title: 'New title' }),
33
+ );
34
+ expect(isCosmeticOnlyJsonSchemaChange(commits, 'actors/foo/actor.json')).toBe(true);
35
+ });
36
+
37
+ test('returns true when only description changes', () => {
38
+ mockGitCalls(
39
+ JSON.stringify({ type: 'string', description: 'Old desc' }),
40
+ JSON.stringify({ type: 'string', description: 'New desc' }),
41
+ );
42
+ expect(isCosmeticOnlyJsonSchemaChange(commits, 'actors/foo/actor.json')).toBe(true);
43
+ });
44
+
45
+ test('returns true when only example changes', () => {
46
+ mockGitCalls(
47
+ JSON.stringify({ type: 'string', example: 'foo' }),
48
+ JSON.stringify({ type: 'string', example: 'bar' }),
49
+ );
50
+ expect(isCosmeticOnlyJsonSchemaChange(commits, 'actors/foo/actor.json')).toBe(true);
51
+ });
52
+
53
+ test('returns true when only enumTitles changes', () => {
54
+ mockGitCalls(
55
+ JSON.stringify({ type: 'string', enum: ['a', 'b'], enumTitles: ['Option A', 'Option B'] }),
56
+ JSON.stringify({ type: 'string', enum: ['a', 'b'], enumTitles: ['Choice A', 'Choice B'] }),
57
+ );
58
+ expect(isCosmeticOnlyJsonSchemaChange(commits, 'actors/foo/actor.json')).toBe(true);
59
+ });
60
+
61
+ test('returns true when only sectionCaption changes', () => {
62
+ mockGitCalls(
63
+ JSON.stringify({ sectionCaption: 'Old caption' }),
64
+ JSON.stringify({ sectionCaption: 'New caption' }),
65
+ );
66
+ expect(isCosmeticOnlyJsonSchemaChange(commits, 'actors/foo/actor.json')).toBe(true);
67
+ });
68
+
69
+ test('returns true when only sectionDescription changes', () => {
70
+ mockGitCalls(JSON.stringify({ sectionDescription: 'Old' }), JSON.stringify({ sectionDescription: 'New' }));
71
+ expect(isCosmeticOnlyJsonSchemaChange(commits, 'actors/foo/actor.json')).toBe(true);
72
+ });
73
+
74
+ test('returns false when a functional field (type) changes', () => {
75
+ mockGitCalls(
76
+ JSON.stringify({ type: 'string', title: 'My field' }),
77
+ JSON.stringify({ type: 'integer', title: 'My field' }),
78
+ );
79
+ expect(isCosmeticOnlyJsonSchemaChange(commits, 'actors/foo/actor.json')).toBe(false);
80
+ });
81
+
82
+ test('returns false when a functional field is added', () => {
83
+ mockGitCalls(JSON.stringify({ title: 'My field' }), JSON.stringify({ title: 'My field', type: 'string' }));
84
+ expect(isCosmeticOnlyJsonSchemaChange(commits, 'actors/foo/actor.json')).toBe(false);
85
+ });
86
+
87
+ test('returns false when a functional field is removed', () => {
88
+ mockGitCalls(JSON.stringify({ type: 'string', title: 'My field' }), JSON.stringify({ title: 'My field' }));
89
+ expect(isCosmeticOnlyJsonSchemaChange(commits, 'actors/foo/actor.json')).toBe(false);
90
+ });
91
+
92
+ test('returns true when non-functional fields change at nested level (input schema properties)', () => {
93
+ mockGitCalls(
94
+ JSON.stringify({
95
+ type: 'object',
96
+ properties: {
97
+ myField: { type: 'string', title: 'Old title', description: 'Old desc', example: 'old' },
98
+ },
99
+ }),
100
+ JSON.stringify({
101
+ type: 'object',
102
+ properties: {
103
+ myField: { type: 'string', title: 'New title', description: 'New desc', example: 'new' },
104
+ },
105
+ }),
106
+ );
107
+ expect(isCosmeticOnlyJsonSchemaChange(commits, 'actors/foo/actor.json')).toBe(true);
108
+ });
109
+
110
+ test('returns false when a functional nested field changes alongside non-functional ones', () => {
111
+ mockGitCalls(
112
+ JSON.stringify({
113
+ type: 'object',
114
+ properties: { myField: { type: 'string', title: 'Old title' } },
115
+ }),
116
+ JSON.stringify({
117
+ type: 'object',
118
+ properties: { myField: { type: 'integer', title: 'New title' } },
119
+ }),
120
+ );
121
+ expect(isCosmeticOnlyJsonSchemaChange(commits, 'actors/foo/actor.json')).toBe(false);
122
+ });
123
+
124
+ test('returns false when a new property is added to input schema', () => {
125
+ mockGitCalls(
126
+ JSON.stringify({ properties: { fieldA: { type: 'string' } } }),
127
+ JSON.stringify({ properties: { fieldA: { type: 'string' }, fieldB: { type: 'integer' } } }),
128
+ );
129
+ expect(isCosmeticOnlyJsonSchemaChange(commits, 'actors/foo/actor.json')).toBe(false);
130
+ });
131
+
132
+ test('returns false when a property is removed from input schema', () => {
133
+ mockGitCalls(
134
+ JSON.stringify({ properties: { fieldA: { type: 'string' }, fieldB: { type: 'integer' } } }),
135
+ JSON.stringify({ properties: { fieldA: { type: 'string' } } }),
136
+ );
137
+ expect(isCosmeticOnlyJsonSchemaChange(commits, 'actors/foo/actor.json')).toBe(false);
138
+ });
139
+
140
+ test('returns false when invalid JSON in old content', () => {
141
+ mockGitCalls('not json', '{}');
142
+ expect(isCosmeticOnlyJsonSchemaChange(commits, 'actors/foo/actor.json')).toBe(false);
143
+ });
144
+
145
+ test('returns false when invalid JSON in new content', () => {
146
+ mockGitCalls('{}', 'not json');
147
+ expect(isCosmeticOnlyJsonSchemaChange(commits, 'actors/foo/actor.json')).toBe(false);
148
+ });
149
+
150
+ test('returns false when array content changes (not under a non-functional key)', () => {
151
+ mockGitCalls(JSON.stringify({ enum: [1, 2, 3] }), JSON.stringify({ enum: [1, 2, 4] }));
152
+ expect(isCosmeticOnlyJsonSchemaChange(commits, 'actors/foo/actor.json')).toBe(false);
153
+ });
154
+
155
+ test('returns true when example array changes (non-functional key)', () => {
156
+ mockGitCalls(
157
+ JSON.stringify({ type: 'array', example: [1, 2, 3] }),
158
+ JSON.stringify({ type: 'array', example: [4, 5, 6] }),
159
+ );
160
+ expect(isCosmeticOnlyJsonSchemaChange(commits, 'actors/foo/actor.json')).toBe(true);
161
+ });
162
+
163
+ test('returns true for a realistic actor.json with only title/description change', () => {
164
+ mockGitCalls(
165
+ JSON.stringify({
166
+ actorSpecification: 1,
167
+ name: 'my-actor',
168
+ title: 'Old Title',
169
+ description: 'Old description',
170
+ version: '1.0',
171
+ }),
172
+ JSON.stringify({
173
+ actorSpecification: 1,
174
+ name: 'my-actor',
175
+ title: 'New Title',
176
+ description: 'New description',
177
+ version: '1.0',
178
+ }),
179
+ );
180
+ expect(isCosmeticOnlyJsonSchemaChange(commits, 'actors/foo/actor.json')).toBe(true);
181
+ });
182
+
183
+ test('returns true when fields under properties are reordered', () => {
184
+ mockGitCalls(
185
+ JSON.stringify({
186
+ type: 'object',
187
+ properties: { fieldA: { type: 'string' }, fieldB: { type: 'integer' }, fieldC: { type: 'boolean' } },
188
+ }),
189
+ JSON.stringify({
190
+ type: 'object',
191
+ properties: { fieldC: { type: 'boolean' }, fieldA: { type: 'string' }, fieldB: { type: 'integer' } },
192
+ }),
193
+ );
194
+ expect(isCosmeticOnlyJsonSchemaChange(commits, 'actors/foo/actor.json')).toBe(true);
195
+ });
196
+
197
+ test('returns false for a realistic actor.json with version change', () => {
198
+ mockGitCalls(
199
+ JSON.stringify({ actorSpecification: 1, name: 'my-actor', title: 'My Actor', version: '1.0' }),
200
+ JSON.stringify({ actorSpecification: 1, name: 'my-actor', title: 'My Actor', version: '1.1' }),
201
+ );
202
+ expect(isCosmeticOnlyJsonSchemaChange(commits, 'actors/foo/actor.json')).toBe(false);
203
+ });
204
+
205
+ it('uses correct git refs: first-commit parent for old, last commit for new', () => {
206
+ const json = JSON.stringify({});
207
+ mockGitCalls(json, json);
208
+ isCosmeticOnlyJsonSchemaChange(commits, 'actors/foo/actor.json');
209
+ expect(gitCommandSpy).toHaveBeenCalledWith('git show Commit1~:actors/foo/actor.json');
210
+ expect(gitCommandSpy).toHaveBeenCalledWith('git show Commit3:actors/foo/actor.json');
211
+ });
212
+ });
@@ -1,14 +1,20 @@
1
- import { beforeEach, describe, expect, it, MockInstance, vi } from 'vitest';
2
- import { getChangedFiles, getCommits } from '../../../bin/git.js';
1
+ import type { MockInstance } from 'vitest';
2
+ import { beforeEach, describe, expect, it, vi } from 'vitest';
3
+
4
+ import { getChangedFiles, getCommits, parseBaseCommit } from '../../../bin/git.js';
3
5
  import * as Utils from '../../../bin/utils.js';
4
6
 
5
7
  describe('getCommits', () => {
6
8
  const sourceBranch = 'feature-branch';
7
9
  const targetBranch = 'main';
8
10
 
9
- const commit1 = 'Commit1»¦«Author1»¦«Date1»¦«First Change On Feature';
10
- const commit2 = 'Commit2»¦«Author1»¦«Date2»¦«Second Change On Feature';
11
- const commit3 = 'Commit3»¦«Author1»¦«Date3»¦«Third Change On Feature';
11
+ const sha1 = '1'.repeat(40);
12
+ const sha2 = '2'.repeat(40);
13
+ const sha3 = '3'.repeat(40);
14
+
15
+ const commit1 = `${sha1}»¦«Author1»¦«Date1»¦«First Change On Feature`;
16
+ const commit2 = `${sha2}»¦«Author1»¦«Date2»¦«Second Change On Feature`;
17
+ const commit3 = `${sha3}»¦«Author1»¦«Date3»¦«Third Change On Feature`;
12
18
 
13
19
  let gitCommandSpy: MockInstance;
14
20
 
@@ -24,9 +30,9 @@ describe('getCommits', () => {
24
30
 
25
31
  // Assert
26
32
  expect(commits).toStrictEqual([
27
- { sha: 'Commit1', author: 'Author1', date: 'Date1', message: 'First Change On Feature' },
28
- { sha: 'Commit2', author: 'Author1', date: 'Date2', message: 'Second Change On Feature' },
29
- { sha: 'Commit3', author: 'Author1', date: 'Date3', message: 'Third Change On Feature' },
33
+ { sha: sha1, author: 'Author1', date: 'Date1', message: 'First Change On Feature' },
34
+ { sha: sha2, author: 'Author1', date: 'Date2', message: 'Second Change On Feature' },
35
+ { sha: sha3, author: 'Author1', date: 'Date3', message: 'Third Change On Feature' },
30
36
  ]);
31
37
 
32
38
  expect(gitCommandSpy).toHaveBeenCalledTimes(1);
@@ -37,12 +43,12 @@ describe('getCommits', () => {
37
43
 
38
44
  it('should return commits after the base commit if provided', () => {
39
45
  // Act
40
- const commits = getCommits({ sourceBranch, targetBranch, baseCommit: 'Commit1' });
46
+ const commits = getCommits({ sourceBranch, targetBranch, baseCommit: sha1 });
41
47
 
42
48
  // Assert
43
49
  expect(commits).toStrictEqual([
44
- { sha: 'Commit2', author: 'Author1', date: 'Date2', message: 'Second Change On Feature' },
45
- { sha: 'Commit3', author: 'Author1', date: 'Date3', message: 'Third Change On Feature' },
50
+ { sha: sha2, author: 'Author1', date: 'Date2', message: 'Second Change On Feature' },
51
+ { sha: sha3, author: 'Author1', date: 'Date3', message: 'Third Change On Feature' },
46
52
  ]);
47
53
 
48
54
  expect(gitCommandSpy).toHaveBeenCalledTimes(1);
@@ -53,13 +59,13 @@ describe('getCommits', () => {
53
59
 
54
60
  it('should return all commits if base commit is not found', () => {
55
61
  // Act
56
- const commits = getCommits({ sourceBranch, targetBranch, baseCommit: 'NonExistingCommit' });
62
+ const commits = getCommits({ sourceBranch, targetBranch, baseCommit: 'a'.repeat(40) });
57
63
 
58
64
  // Assert
59
65
  expect(commits).toStrictEqual([
60
- { sha: 'Commit1', author: 'Author1', date: 'Date1', message: 'First Change On Feature' },
61
- { sha: 'Commit2', author: 'Author1', date: 'Date2', message: 'Second Change On Feature' },
62
- { sha: 'Commit3', author: 'Author1', date: 'Date3', message: 'Third Change On Feature' },
66
+ { sha: sha1, author: 'Author1', date: 'Date1', message: 'First Change On Feature' },
67
+ { sha: sha2, author: 'Author1', date: 'Date2', message: 'Second Change On Feature' },
68
+ { sha: sha3, author: 'Author1', date: 'Date3', message: 'Third Change On Feature' },
63
69
  ]);
64
70
 
65
71
  expect(gitCommandSpy).toHaveBeenCalledTimes(1);
@@ -78,9 +84,11 @@ describe('getChangedFiles', () => {
78
84
 
79
85
  it('should return changed files between commits', () => {
80
86
  // Arrange
87
+ const firstSha = '1'.repeat(40);
88
+ const lastSha = '3'.repeat(40);
81
89
  const commits = [
82
- { sha: 'Commit1', author: '', date: '', message: '' },
83
- { sha: 'Commit3', author: '', date: '', message: '' },
90
+ { sha: firstSha, author: '', date: '', message: '' },
91
+ { sha: lastSha, author: '', date: '', message: '' },
84
92
  ];
85
93
 
86
94
  // Act
@@ -90,12 +98,13 @@ describe('getChangedFiles', () => {
90
98
  expect(changedFiles).toStrictEqual(['file1.txt', 'folder/file2.txt']);
91
99
 
92
100
  expect(gitCommandSpy).toHaveBeenCalledTimes(1);
93
- expect(gitCommandSpy).toHaveBeenCalledWith(`git diff --name-only Commit1~..Commit3`);
101
+ expect(gitCommandSpy).toHaveBeenCalledWith(`git diff --name-only ${firstSha}~..${lastSha}`);
94
102
  });
95
103
 
96
104
  it('should handle only one commit', () => {
97
105
  // Arrange
98
- const commits = [{ sha: 'Commit1', author: '', date: '', message: '' }];
106
+ const onlySha = '1'.repeat(40);
107
+ const commits = [{ sha: onlySha, author: '', date: '', message: '' }];
99
108
 
100
109
  // Act
101
110
  const changedFiles = getChangedFiles(commits);
@@ -104,6 +113,36 @@ describe('getChangedFiles', () => {
104
113
  expect(changedFiles).toStrictEqual(['file1.txt', 'folder/file2.txt']);
105
114
 
106
115
  expect(gitCommandSpy).toHaveBeenCalledTimes(1);
107
- expect(gitCommandSpy).toHaveBeenCalledWith(`git diff --name-only Commit1~..Commit1`);
116
+ expect(gitCommandSpy).toHaveBeenCalledWith(`git diff --name-only ${onlySha}~..${onlySha}`);
117
+ });
118
+ });
119
+
120
+ const VALID_SHA = 'a'.repeat(40);
121
+ const VALID_JSON = JSON.stringify({ sha: VALID_SHA, author: 'test', date: 'now', message: 'msg' });
122
+
123
+ describe('parseBaseCommit', () => {
124
+ it('should return undefined for undefined input', () => {
125
+ expect(parseBaseCommit(undefined)).toBeUndefined();
126
+ });
127
+
128
+ it('should return undefined for empty string', () => {
129
+ expect(parseBaseCommit('')).toBeUndefined();
130
+ });
131
+
132
+ it('should accept a plain SHA string', () => {
133
+ expect(parseBaseCommit(VALID_SHA)).toBe(VALID_SHA);
134
+ });
135
+
136
+ it('should extract sha from a JSON commit object', () => {
137
+ expect(parseBaseCommit(VALID_JSON)).toBe(VALID_SHA);
138
+ });
139
+
140
+ it('should throw on an invalid SHA string', () => {
141
+ expect(() => parseBaseCommit('not-a-sha')).toThrow('Invalid base commit SHA');
142
+ });
143
+
144
+ it('should throw when JSON contains an invalid sha field', () => {
145
+ const badJson = JSON.stringify({ sha: 'bad', author: 'test', date: 'now', message: 'msg' });
146
+ expect(() => parseBaseCommit(badJson)).toThrow('Invalid base commit SHA');
108
147
  });
109
148
  });
@@ -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,
@@ -1,4 +1,5 @@
1
- import { describe, it, expect } from 'vitest';
1
+ import { describe, expect, it } from 'vitest';
2
+
2
3
  import { GIT_FORMAT_SEPARATOR, parseCommit } from '../../bin/git.js';
3
4
 
4
5
  describe('parseCommit', () => {