apify-test-tools 0.10.2-beta.20 → 0.10.2-beta.21

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/docs/cli.md CHANGED
@@ -309,7 +309,11 @@ they name it by. An Actor the token can't see keeps only the ID it was listed wi
309
309
  Actor no test uses doesn't stop the run. A dry-run plan, empty or invalid input is an error, as with `build`. So is a
310
310
  missing `TESTER_APIFY_TOKEN`: without it the lib skips every platform test, and the run would pass having tested
311
311
  nothing. `test` passes the Actors to vitest as `ACTOR_BUILDS`, in place of any
312
- `ACTOR_BUILDS` in its own environment.
312
+ `ACTOR_BUILDS` in its own environment. For older lib versions, it also lists each Actor's IDs as `actorName` and
313
+ `actorId`, the names versions before 0.9.0 read. It sets `RUN_PLATFORM_TESTS=1`, which versions before 0.10.0 need to
314
+ run their `describe` blocks, and removes `RUN_ALL_PLATFORM_TESTS`, which would make those versions run the tests of
315
+ every Actor. When it is given Actors but every test is skipped, it logs a warning, since that usually means the tests
316
+ name the Actors differently.
313
317
 
314
318
  It runs vitest with `--maxConcurrency=20 --fileParallelism --maxWorkers=100`, since platform tests mostly wait on
315
319
  Actor runs rather than the CPU, and with the default reporter plus the JSON one the report is read from. These
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apify-test-tools",
3
- "version": "0.10.2-beta.20",
3
+ "version": "0.10.2-beta.21",
4
4
  "type": "module",
5
5
  "description": "TBD",
6
6
  "repository": {
@@ -47,6 +47,21 @@ test('owner/a: fails', () => {
47
47
  );
48
48
 
49
49
  // Outside test/platform, so the tests that run test/platform don't see them
50
+ // Lib versions before 0.10.0 run their describe only with RUN_PLATFORM_TESTS set
51
+ await mkdir(path.join(repoDir, 'test/old-lib'), { recursive: true });
52
+ await writeFile(
53
+ path.join(repoDir, 'test/old-lib/old.test.ts'),
54
+ `import { describe, test } from 'vitest';\n\n` +
55
+ `describe.runIf(!!process.env.RUN_PLATFORM_TESTS)('old lib', () => {\n` +
56
+ ` test('owner/a: runs', () => {});\n` +
57
+ `});\n`,
58
+ );
59
+ await mkdir(path.join(repoDir, 'test/skipped'), { recursive: true });
60
+ await writeFile(
61
+ path.join(repoDir, 'test/skipped/skipped.test.ts'),
62
+ `import { test } from 'vitest';\n\ntest.skip('owner/a: skipped', () => {});\n`,
63
+ );
64
+
50
65
  for (const folder of ['with-pr', 'without-pr']) {
51
66
  await mkdir(path.join(repoDir, 'test/glob', folder), { recursive: true });
52
67
  await writeFile(
@@ -66,7 +81,10 @@ test('owner/a: fails', () => {
66
81
  expect(result.status).toBe(1);
67
82
  // Passed on to the lib as ACTOR_BUILDS, the fields in the order test reads them
68
83
  const { actorFullName, buildId, actorRawId, buildNumber } = build;
69
- expect(result.stderr).toContain(`ENV ${JSON.stringify([{ actorFullName, buildId, actorRawId, buildNumber }])}`);
84
+ // Also under the names lib versions before 0.9.0 read
85
+ expect(result.stderr).toContain(
86
+ `ENV ${JSON.stringify([{ actorFullName, buildId, actorRawId, buildNumber, actorName: actorFullName, actorId: actorRawId }])}`,
87
+ );
70
88
  expect(result.stderr).toContain('1) owner/a: works ... https://console.apify.com/view/runs/run1');
71
89
  // Vitest's own output still comes through, without the note about the temporary JSON report
72
90
  expect(result.stderr).toContain('Test Files');
@@ -96,7 +114,9 @@ test('owner/a: fails', () => {
96
114
  const result = run(['test'], JSON.stringify([actorConfig]));
97
115
  expect(result.status).toBe(1);
98
116
  // Only the fields the lib reads reach it
99
- expect(result.stderr).toContain('ENV [{"actorFullName":"owner/a","actorRawId":"raw1"}]');
117
+ expect(result.stderr).toContain(
118
+ 'ENV [{"actorFullName":"owner/a","actorRawId":"raw1","actorName":"owner/a","actorId":"raw1"}]',
119
+ );
100
120
  expect(result.stderr).toContain('Testing 1 Actor(s): owner/a (default build)');
101
121
  expect(JSON.parse(result.stdout)).toMatchObject({ success: false, summary: { passed: 1, failed: 1 } });
102
122
  });
@@ -132,6 +152,18 @@ test('owner/a: fails', () => {
132
152
  expect(result.stdout).toBe('');
133
153
  });
134
154
 
155
+ it('runs the describe blocks of lib versions before 0.10.0, which need RUN_PLATFORM_TESTS', () => {
156
+ const result = run(['test', '--test-files-glob', 'test/old-lib/**'], JSON.stringify([build]));
157
+ expect(result.status, result.stderr).toBe(0);
158
+ expect(JSON.parse(result.stdout)).toMatchObject({ summary: { total: 1, passed: 1, skipped: 0 } });
159
+ });
160
+
161
+ it('warns when every test was skipped although Actors were given', () => {
162
+ const result = run(['test', '--test-files-glob', 'test/skipped/**'], JSON.stringify([build]));
163
+ expect(result.status, result.stderr).toBe(0);
164
+ expect(result.stderr).toContain('Every test was skipped, although 1 Actor(s) were given');
165
+ });
166
+
135
167
  it('rejects test paths given the old way, as arguments, instead of running every test', () => {
136
168
  const result = run(['test', 'test/platform/core'], JSON.stringify([build]));
137
169
  expect(result.status).toBe(1);