Skip to content

Commit

Permalink
test: add shard e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
marionebl committed Mar 4, 2022
1 parent edcd51b commit 8a6d66f
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 0 deletions.
52 changes: 52 additions & 0 deletions 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([]);
});
13 changes: 13 additions & 0 deletions 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));
13 changes: 13 additions & 0 deletions 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));
13 changes: 13 additions & 0 deletions 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));
5 changes: 5 additions & 0 deletions e2e/shard/package.json
@@ -0,0 +1,5 @@
{
"jest": {
"testEnvironment": "node"
}
}

0 comments on commit 8a6d66f

Please sign in to comment.