apify-test-tools 0.10.1-beta.2 → 0.10.1-beta.3

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apify-test-tools",
3
- "version": "0.10.1-beta.2",
3
+ "version": "0.10.1-beta.3",
4
4
  "type": "module",
5
5
  "description": "TBD",
6
6
  "repository": {
@@ -47,7 +47,7 @@
47
47
  },
48
48
  "scripts": {
49
49
  "start": "npm run dist/bin/main.js",
50
- "start:dev": "tsx bin/main.ts --workspace local-clone",
50
+ "start:dev": "cd local-clone && tsx ../bin/main.ts",
51
51
  "build": "tsc && chmod +x ./dist/bin/main.js",
52
52
  "lint": "eslint",
53
53
  "lint:fix": "eslint --fix",
@@ -150,7 +150,7 @@ describe('build-from-local helpers', () => {
150
150
 
151
151
  const originalCwd = process.cwd();
152
152
  // We simulate the working directory being the repo root, since collectSourceFiles uses relative paths to the repo root.
153
- Utils.setCwd({ workspace: repoRoot });
153
+ process.chdir(repoRoot);
154
154
  try {
155
155
  const cwd = process.cwd();
156
156
  const actorDir = path.join(cwd, 'actors', 'owner_actor');
@@ -13,7 +13,7 @@ describe('isCosmeticOnlyJsonSchemaChange', () => {
13
13
  let gitCommandSpy: MockInstance;
14
14
 
15
15
  beforeEach(() => {
16
- gitCommandSpy = vi.spyOn(Utils, 'spawnCommandInGhWorkspace');
16
+ gitCommandSpy = vi.spyOn(Utils, 'spawnCommand');
17
17
  });
18
18
 
19
19
  const mockGitCalls = (oldJson: string, newJson: string) => {
@@ -30,9 +30,7 @@ describe('getCommits', () => {
30
30
  let gitCommandSpy: MockInstance;
31
31
 
32
32
  beforeEach(() => {
33
- gitCommandSpy = vi
34
- .spyOn(Utils, 'spawnCommandInGhWorkspace')
35
- .mockReturnValue(`${commit3}\n${commit2}\n${commit1}`);
33
+ gitCommandSpy = vi.spyOn(Utils, 'spawnCommand').mockReturnValue(`${commit3}\n${commit2}\n${commit1}`);
36
34
  });
37
35
 
38
36
  it('should return commits between source and target branches', () => {
@@ -102,7 +100,7 @@ describe('getChangedFiles', () => {
102
100
  let gitCommandSpy: MockInstance;
103
101
 
104
102
  beforeEach(() => {
105
- gitCommandSpy = vi.spyOn(Utils, 'spawnCommandInGhWorkspace').mockReturnValue('file1.txt\nfolder/file2.txt');
103
+ gitCommandSpy = vi.spyOn(Utils, 'spawnCommand').mockReturnValue('file1.txt\nfolder/file2.txt');
106
104
  });
107
105
 
108
106
  it('should return changed files between commits', () => {
@@ -171,7 +169,7 @@ describe('hasMergeFromTarget', () => {
171
169
  let gitCommandSpy: MockInstance;
172
170
 
173
171
  beforeEach(() => {
174
- gitCommandSpy = vi.spyOn(Utils, 'spawnCommandInGhWorkspace');
172
+ gitCommandSpy = vi.spyOn(Utils, 'spawnCommand');
175
173
  });
176
174
 
177
175
  it('should return false when there are no merge commits on the branch', () => {
@@ -220,7 +218,7 @@ describe('getBranchOnlyChangedFiles', () => {
220
218
  let gitCommandSpy: MockInstance;
221
219
 
222
220
  beforeEach(() => {
223
- gitCommandSpy = vi.spyOn(Utils, 'spawnCommandInGhWorkspace');
221
+ gitCommandSpy = vi.spyOn(Utils, 'spawnCommand');
224
222
  });
225
223
 
226
224
  it('should return files touched by non-merge commits', () => {
@@ -273,12 +271,12 @@ describe('parseBaseCommit', () => {
273
271
 
274
272
  describe('getCurrentBranch', () => {
275
273
  it('should return the checked-out branch', () => {
276
- vi.spyOn(Utils, 'spawnCommandInGhWorkspace').mockReturnValue('master');
274
+ vi.spyOn(Utils, 'spawnCommand').mockReturnValue('master');
277
275
  expect(getCurrentBranch()).toBe('master');
278
276
  });
279
277
 
280
278
  it('should throw on a detached HEAD', () => {
281
- vi.spyOn(Utils, 'spawnCommandInGhWorkspace').mockReturnValue('HEAD');
279
+ vi.spyOn(Utils, 'spawnCommand').mockReturnValue('HEAD');
282
280
  expect(() => getCurrentBranch()).toThrow('HEAD is detached');
283
281
  });
284
282
  });
@@ -313,7 +311,7 @@ describe('resolveReleaseBaseCommit', () => {
313
311
  const baseSha = 'b'.repeat(40);
314
312
 
315
313
  it('should return the base commit when it is an ancestor of HEAD', () => {
316
- vi.spyOn(Utils, 'spawnCommandInGhWorkspace').mockImplementation((cmd: string) => {
314
+ vi.spyOn(Utils, 'spawnCommand').mockImplementation((cmd: string) => {
317
315
  if (cmd.startsWith('git rev-parse --verify')) return baseSha;
318
316
  if (cmd.startsWith('git merge-base')) return baseSha;
319
317
  return '';
@@ -322,18 +320,18 @@ describe('resolveReleaseBaseCommit', () => {
322
320
  });
323
321
 
324
322
  it('should throw on the all-zeros SHA of a newly created branch', () => {
325
- const spy = vi.spyOn(Utils, 'spawnCommandInGhWorkspace');
323
+ const spy = vi.spyOn(Utils, 'spawnCommand');
326
324
  expect(() => resolveReleaseBaseCommit('0'.repeat(40))).toThrow('the branch was just created');
327
325
  expect(spy).not.toHaveBeenCalled();
328
326
  });
329
327
 
330
328
  it('should throw when the base commit is missing from the local history', () => {
331
- vi.spyOn(Utils, 'spawnCommandInGhWorkspace').mockReturnValue('');
329
+ vi.spyOn(Utils, 'spawnCommand').mockReturnValue('');
332
330
  expect(() => resolveReleaseBaseCommit(baseSha)).toThrow('is not in the local git history');
333
331
  });
334
332
 
335
333
  it('should throw when the base commit is not an ancestor of HEAD (force push)', () => {
336
- vi.spyOn(Utils, 'spawnCommandInGhWorkspace').mockImplementation((cmd: string) => {
334
+ vi.spyOn(Utils, 'spawnCommand').mockImplementation((cmd: string) => {
337
335
  if (cmd.startsWith('git rev-parse --verify')) return baseSha;
338
336
  if (cmd.startsWith('git merge-base')) return 'c'.repeat(40);
339
337
  return '';
@@ -355,7 +353,7 @@ describe('getReleaseChanges', () => {
355
353
  let gitCommandSpy: MockInstance;
356
354
 
357
355
  beforeEach(() => {
358
- gitCommandSpy = vi.spyOn(Utils, 'spawnCommandInGhWorkspace').mockImplementation((cmd: string) => {
356
+ gitCommandSpy = vi.spyOn(Utils, 'spawnCommand').mockImplementation((cmd: string) => {
359
357
  if (cmd === 'git rev-parse HEAD') return headSha;
360
358
  if (cmd.startsWith('git log')) return `${mergeCommit}\n${mergedBranchCommit}`;
361
359
  if (cmd.startsWith('git diff --name-only')) return 'actors/foo/src/main.ts\nCHANGELOG.md';