-
Notifications
You must be signed in to change notification settings - Fork 453
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: hoisting + tests + many other things
- Loading branch information
Showing
31 changed files
with
519 additions
and
616 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
# TypeScript source code | ||
src | ||
|
||
# Tests | ||
tests | ||
e2e | ||
test | ||
|
||
# Developement scripts | ||
scripts | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import hello from './hello'; | ||
|
||
jest.mock('./hello'); | ||
|
||
describe('hello', () => { | ||
const original = require.requireActual('./hello').default; | ||
it('should have been mocked', () => { | ||
const msg = hello(); | ||
expect(hello).not.toBe(original); | ||
expect(msg).toBeUndefined(); | ||
expect(hello).toHaveProperty('mock'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function() { | ||
return 'hi!'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Hoisting test with template "default" should pass 1`] = ` | ||
jest exit code: 0 | ||
===[ STDOUT ]=================================================================== | ||
===[ STDERR ]=================================================================== | ||
PASS ./hello.spec.ts | ||
hello | ||
√ should have been mocked | ||
Test Suites: 1 passed, 1 total | ||
Tests: 1 passed, 1 total | ||
Snapshots: 0 total | ||
Time: XXs | ||
Ran all test suites. | ||
================================================================================ | ||
`; | ||
|
||
exports[`Hoisting test with template "with-babel-6" should pass 1`] = ` | ||
jest exit code: 0 | ||
===[ STDOUT ]=================================================================== | ||
===[ STDERR ]=================================================================== | ||
PASS ./hello.spec.ts | ||
hello | ||
√ should have been mocked | ||
Test Suites: 1 passed, 1 total | ||
Tests: 1 passed, 1 total | ||
Snapshots: 0 total | ||
Time: XXs | ||
Ran all test suites. | ||
================================================================================ | ||
`; | ||
|
||
exports[`Hoisting test with template "with-babel-7" should pass 1`] = ` | ||
jest exit code: 0 | ||
===[ STDOUT ]=================================================================== | ||
===[ STDERR ]=================================================================== | ||
PASS ./hello.spec.ts | ||
hello | ||
√ should have been mocked | ||
Test Suites: 1 passed, 1 total | ||
Tests: 1 passed, 1 total | ||
Snapshots: 0 total | ||
Time: XXs | ||
Ran all test suites. | ||
================================================================================ | ||
`; | ||
|
||
exports[`Hoisting test with template "with-jest-22" should pass 1`] = ` | ||
jest exit code: 0 | ||
===[ STDOUT ]=================================================================== | ||
===[ STDERR ]=================================================================== | ||
PASS ./hello.spec.ts | ||
hello | ||
√ should have been mocked | ||
Test Suites: 1 passed, 1 total | ||
Tests: 1 passed, 1 total | ||
Snapshots: 0 total | ||
Time: XXs | ||
Ran all test suites. | ||
================================================================================ | ||
`; |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { configureTestCase } from '../__helpers__/test-case'; | ||
import { allPackageSets } from '../__helpers__/templates'; | ||
|
||
describe('Hoisting test', () => { | ||
const testCase = configureTestCase('hoisting', { args: ['--no-cache'] }); | ||
|
||
testCase.runWithTemplates( | ||
allPackageSets, | ||
0, | ||
(runTest, { describeLabel, itLabel }) => { | ||
describe(describeLabel, () => { | ||
it(itLabel, () => { | ||
const result = runTest(); | ||
expect(result.status).toBe(0); | ||
expect(result).toMatchSnapshot(); | ||
}); | ||
}); | ||
}, | ||
); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { configureTestCase } from '../__helpers__/test-case'; | ||
import { allPackageSets } from '../__helpers__/templates'; | ||
|
||
describe('Simple test', () => { | ||
const testCase = configureTestCase('simple', { args: ['--no-cache'] }); | ||
|
||
testCase.runWithTemplates( | ||
allPackageSets, | ||
0, | ||
(runTest, { describeLabel, itLabel }) => { | ||
describe(describeLabel, () => { | ||
it(itLabel, () => { | ||
const result = runTest(); | ||
expect(result.status).toBe(0); | ||
expect(result).toMatchSnapshot(); | ||
}); | ||
}); | ||
}, | ||
); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { configureTestCase } from '../__helpers__/test-case'; | ||
import { allPackageSets } from '../__helpers__/templates'; | ||
|
||
describe('Source maps', () => { | ||
describe('console.log()', () => { | ||
const testCase = configureTestCase('source-maps', { args: ['--no-cache'] }); | ||
|
||
testCase.runWithTemplates( | ||
allPackageSets, | ||
0, | ||
(runTest, { describeLabel }) => { | ||
describe(describeLabel, () => { | ||
it('should pass reporting correct line number', () => { | ||
const result = runTest(); | ||
expect(result.status).toBe(0); | ||
expect(result).toMatchSnapshot(); | ||
}); | ||
}); | ||
}, | ||
); | ||
}); | ||
|
||
describe('throw new Error()', () => { | ||
const testCase = configureTestCase('source-maps', { | ||
args: ['--no-cache'], | ||
env: { __FORCE_FAIL: '1' }, | ||
}); | ||
|
||
testCase.runWithTemplates( | ||
allPackageSets, | ||
1, | ||
(runTest, { describeLabel }) => { | ||
describe(describeLabel, () => { | ||
it('should fail reporting correct line number', () => { | ||
const result = runTest(); | ||
expect(result.status).toBe(1); | ||
expect(result).toMatchSnapshot(); | ||
}); | ||
}); | ||
}, | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module.exports = { | ||
transform: { | ||
'\\.ts$': '<rootDir>/../dist/index.js', | ||
}, | ||
testRegex: '/__tests__/.+\\.test\\.ts$', | ||
collectCoverageFrom: ['<rootDir>/../src/**/*.ts'], | ||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json'], | ||
testEnvironment: 'node', | ||
snapshotSerializers: ['<rootDir>/__serializers__/test-run-result.ts'], | ||
}; |
Oops, something went wrong.