Skip to content

Commit 9343c7d

Browse files
committed
test: improvments + test helpers
1 parent faae274 commit 9343c7d

42 files changed

Lines changed: 6210 additions & 439 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jspm_packages
4848
# tests specific
4949
tests/simple-long-path/long-src-path
5050
# is linked to the temp dir of the os
51-
e2e/__e2e_workdir_link__
51+
e2e/__workdir_synlink__
5252

5353
# binaries
5454
*.tgz

e2e/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
- `__templates__`: contains the package dependency templates for test cases
88
- `__templates__/default`: is the default template
99
- `__tests__`: contains the actual tests
10-
- `__e2e_workdir_link__`: is created during a test run and is a symbolic link to a subfolder in the temp folder of the OS where all test cases are installed
10+
- `__workdir_synlink__`: is created during a test run and is a symbolic link to a subfolder in the temp folder of the OS where all test cases are installed
1111

1212

1313
## Test helpers
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { Hello } from './Hello';
2+
3+
jest.mock('./Hello', () => ({ Hello() {} }));
4+
5+
describe('Hello Class', () => {
6+
// tslint:disable-next-line:variable-name
7+
const OriginalClass = require.requireActual('./Hello').Hello;
8+
it('should create a new mocked Hello', () => {
9+
const hello = new Hello('foo');
10+
expect(hello.msg).toBeUndefined();
11+
expect(hello).not.toBeInstanceOf(OriginalClass);
12+
expect(hello).toHaveProperty('mock');
13+
});
14+
});

e2e/__cases__/hoisting/Hello.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export class Hello {
2+
constructor(readonly msg: string) {}
3+
}

e2e/__cases__/simple/__tests__/Hello.test.ts renamed to e2e/__cases__/simple/Hello.spec.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
declare var jest, describe, it, expect;
2-
3-
import { Hello } from '../Hello';
1+
import { Hello } from './Hello';
42

53
describe('Hello Class', () => {
64
it('should create a new Hello', () => {

e2e/__cases__/simple/package.json

Lines changed: 0 additions & 10 deletions
This file was deleted.

e2e/__cases__/simple/tsconfig.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

e2e/__cases__/source-maps/test/echo.spec.ts renamed to e2e/__cases__/source-maps/echo.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { echo } from '../src/echo';
1+
import { echo } from './echo';
22

33
describe('echo', () => {
44
it('echoes', () => {

e2e/__cases__/source-maps/package.json

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)