From 8a6d66fb052366787344b6bc532ca6ae495411d3 Mon Sep 17 00:00:00 2001 From: Mario Nebl Date: Fri, 4 Mar 2022 21:49:35 +1100 Subject: [PATCH] test: add shard e2e test --- e2e/__tests__/shard.test.ts | 52 +++++++++++++++++++++++++++++++++++ e2e/shard/__tests__/1.test.js | 13 +++++++++ e2e/shard/__tests__/2.test.js | 13 +++++++++ e2e/shard/__tests__/3.test.js | 13 +++++++++ e2e/shard/package.json | 5 ++++ 5 files changed, 96 insertions(+) create mode 100644 e2e/__tests__/shard.test.ts create mode 100644 e2e/shard/__tests__/1.test.js create mode 100644 e2e/shard/__tests__/2.test.js create mode 100644 e2e/shard/__tests__/3.test.js create mode 100644 e2e/shard/package.json diff --git a/e2e/__tests__/shard.test.ts b/e2e/__tests__/shard.test.ts new file mode 100644 index 000000000000..6f7efbafa092 --- /dev/null +++ b/e2e/__tests__/shard.test.ts @@ -0,0 +1,52 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +import * as path from 'path'; +import runJest from '../runJest'; + +test('--shard=1/1', () => { + const result = runJest('shard', ['--shard=1/1', '--listTests']); + + const paths = result.stdout + .split('\n') + .filter(Boolean) + .map(file => path.basename(file)); + + expect(paths).toEqual(['3.test.js', '2.test.js', '1.test.js']); +}); + +test('--shard=1/2', () => { + const result = runJest('shard', ['--shard=1/2', '--listTests']); + + const paths = result.stdout + .split('\n') + .filter(Boolean) + .map(file => path.basename(file)); + + expect(paths).toEqual(['2.test.js', '1.test.js']); +}); + +test('--shard=2/2', () => { + const result = runJest('shard', ['--shard=2/2', '--listTests']); + + const paths = result.stdout + .split('\n') + .filter(Boolean) + .map(file => path.basename(file)); + + expect(paths).toEqual(['3.test.js']); +}); + +test('--shard=4/4', () => { + const result = runJest('shard', ['--shard=4/4', '--listTests']); + + const paths = result.stdout + .split('\n') + .filter(Boolean) + .map(file => path.basename(file)); + + expect(paths).toEqual([]); +}); diff --git a/e2e/shard/__tests__/1.test.js b/e2e/shard/__tests__/1.test.js new file mode 100644 index 000000000000..8362bdfa2248 --- /dev/null +++ b/e2e/shard/__tests__/1.test.js @@ -0,0 +1,13 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +'use strict'; + +test('1-1', () => expect(2).toBe(2)); + +test('1-2', () => expect(2).toBe(2)); + +test('1-3', () => expect(2).toBe(2)); diff --git a/e2e/shard/__tests__/2.test.js b/e2e/shard/__tests__/2.test.js new file mode 100644 index 000000000000..50faeecd1743 --- /dev/null +++ b/e2e/shard/__tests__/2.test.js @@ -0,0 +1,13 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +'use strict'; + +test('2-1', () => expect(2).toBe(2)); + +test('2-2', () => expect(2).toBe(2)); + +test('2-3', () => expect(2).toBe(2)); diff --git a/e2e/shard/__tests__/3.test.js b/e2e/shard/__tests__/3.test.js new file mode 100644 index 000000000000..1ddf79ff3a36 --- /dev/null +++ b/e2e/shard/__tests__/3.test.js @@ -0,0 +1,13 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +'use strict'; + +test('3-1', () => expect(2).toBe(2)); + +test('3-2', () => expect(2).toBe(2)); + +test('3-3', () => expect(2).toBe(2)); diff --git a/e2e/shard/package.json b/e2e/shard/package.json new file mode 100644 index 000000000000..148788b25446 --- /dev/null +++ b/e2e/shard/package.json @@ -0,0 +1,5 @@ +{ + "jest": { + "testEnvironment": "node" + } +}