Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes paths in coverage on Windows #741

Merged
merged 3 commits into from
Sep 20, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
test(e2e): deep paths and coverage
  • Loading branch information
huafu committed Sep 20, 2018
commit 0141098d2560cd7ab637c867f172470890041394
5 changes: 5 additions & 0 deletions e2e/__cases__/deep/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"scripts": {
"test": "cd src/Tests && jest"
}
}
5 changes: 5 additions & 0 deletions e2e/__cases__/deep/src/Button/click.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import * as mod from './mod'

export function click(foo: string) {
return `clicked ${mod(foo)}`
}
3 changes: 3 additions & 0 deletions e2e/__cases__/deep/src/Button/mod.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
type ModExport = (str: string) => string
declare const _export: ModExport
export = _export
3 changes: 3 additions & 0 deletions e2e/__cases__/deep/src/Button/mod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = function(str) {
return str.toUpperCase()
}
5 changes: 5 additions & 0 deletions e2e/__cases__/deep/src/Tests/Button/click.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { click } from '../../Button/click'

test('button should click!', () => {
expect(click('bar')).toBe('clicked BAR')
})
24 changes: 24 additions & 0 deletions e2e/__cases__/deep/src/Tests/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const cfg = {}

if (require('jest/package.json').version.split('.').shift() === '22') {
Object.assign(cfg, require('ts-jest').jestPreset)
} else {
cfg.preset = 'ts-jest'
}

module.exports = Object.assign({}, cfg, {
collectCoverage: true,
collectCoverageFrom: ["**/*.ts", "!**/*.d.ts", "!**/build/**", "!/FrontEnd/**"],
forceCoverageMatch: ["**/*.test.ts"],
coverageDirectory: "Tests/coverage",
coverageReporters: ["lcov"],
rootDir: "..",
testMatch: ["**/*.test.ts"],
testEnvironment: "node",
globals: {
"ts-jest": {
tsConfig: "./tsconfig.json",
},
},
// testResultsProcessor: "jest-teamcity-reporter",
})
5 changes: 5 additions & 0 deletions e2e/__cases__/deep/src/Tests/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": "../tsconfig.base.node.json",
"compilerOptions": {
}
}
10 changes: 10 additions & 0 deletions e2e/__cases__/deep/src/tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"skipLibCheck": true,
"moduleResolution": "node",
"forceConsistentCasingInFileNames": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"strict": true
}
}
10 changes: 10 additions & 0 deletions e2e/__cases__/deep/src/tsconfig.base.node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"module": "commonjs",
"target": "es2017",
"lib": [
"es2017"
]
}
}
5 changes: 5 additions & 0 deletions e2e/__cases__/deep/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"compilerOptions": {
"esModuleInterop": true
}
}
271 changes: 271 additions & 0 deletions e2e/__tests__/__snapshots__/deep-path.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,271 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Deep paths test should pass using template "default": lcov 1`] = `
"TN:
SF:<cwd>/src/Button/click.ts
FN:3,click
FNF:1
FNH:1
FNDA:1,click
DA:1,1
DA:3,1
DA:4,1
LF:3
LH:3
BRF:0
BRH:0
end_of_record
TN:
SF:<cwd>/src/Tests/Button/click.test.ts
FN:3,(anonymous_0)
FNF:1
FNH:1
FNDA:1,(anonymous_0)
DA:1,1
DA:3,1
DA:4,1
LF:3
LH:3
BRF:0
BRH:0
end_of_record
"
`;

exports[`Deep paths test should pass using template "default": output 1`] = `
√ npm -s run test
↳ exit code: 0
===[ STDOUT ]===================================================================
=============================== Coverage summary ===============================
Statements : 100% ( 6/6 )
Branches : 100% ( 0/0 )
Functions : 100% ( 2/2 )
Lines : 100% ( 6/6 )
================================================================================
===[ STDERR ]===================================================================
PASS Button/click.test.ts
√ button should click!

Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: XXs
Ran all test suites.
================================================================================
`;

exports[`Deep paths test should pass using template "with-babel-6": lcov 1`] = `
"TN:
SF:<cwd>/src/Button/click.ts
FN:3,click
FNF:1
FNH:1
FNDA:1,click
DA:1,1
DA:3,1
DA:4,1
LF:3
LH:3
BRF:0
BRH:0
end_of_record
TN:
SF:<cwd>/src/Tests/Button/click.test.ts
FN:3,(anonymous_0)
FNF:1
FNH:1
FNDA:1,(anonymous_0)
DA:1,1
DA:3,1
DA:4,1
LF:3
LH:3
BRF:0
BRH:0
end_of_record
"
`;

exports[`Deep paths test should pass using template "with-babel-6": output 1`] = `
√ npm -s run test
↳ exit code: 0
===[ STDOUT ]===================================================================
=============================== Coverage summary ===============================
Statements : 100% ( 6/6 )
Branches : 100% ( 0/0 )
Functions : 100% ( 2/2 )
Lines : 100% ( 6/6 )
================================================================================
===[ STDERR ]===================================================================
PASS Button/click.test.ts
√ button should click!

Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: XXs
Ran all test suites.
================================================================================
`;

exports[`Deep paths test should pass using template "with-babel-7": lcov 1`] = `
"TN:
SF:<cwd>/src/Button/click.ts
FN:3,click
FNF:1
FNH:1
FNDA:1,click
DA:1,1
DA:3,1
DA:4,1
LF:3
LH:3
BRF:0
BRH:0
end_of_record
TN:
SF:<cwd>/src/Tests/Button/click.test.ts
FN:3,(anonymous_0)
FNF:1
FNH:1
FNDA:1,(anonymous_0)
DA:1,1
DA:3,1
DA:4,1
LF:3
LH:3
BRF:0
BRH:0
end_of_record
"
`;

exports[`Deep paths test should pass using template "with-babel-7": output 1`] = `
√ npm -s run test
↳ exit code: 0
===[ STDOUT ]===================================================================
=============================== Coverage summary ===============================
Statements : 100% ( 6/6 )
Branches : 100% ( 0/0 )
Functions : 100% ( 2/2 )
Lines : 100% ( 6/6 )
================================================================================
===[ STDERR ]===================================================================
PASS Button/click.test.ts
√ button should click!

Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: XXs
Ran all test suites.
================================================================================
`;

exports[`Deep paths test should pass using template "with-jest-22": lcov 1`] = `
"TN:
SF:<cwd>/src/Button/click.ts
FN:3,click
FNF:1
FNH:1
FNDA:1,click
DA:1,1
DA:3,1
DA:4,1
LF:3
LH:3
BRF:0
BRH:0
end_of_record
TN:
SF:<cwd>/src/Tests/Button/click.test.ts
FN:3,(anonymous_0)
FNF:1
FNH:1
FNDA:1,(anonymous_0)
DA:1,1
DA:3,1
DA:4,1
LF:3
LH:3
BRF:0
BRH:0
end_of_record
"
`;

exports[`Deep paths test should pass using template "with-jest-22": output 1`] = `
√ npm -s run test
↳ exit code: 0
===[ STDOUT ]===================================================================
=============================== Coverage summary ===============================
Statements : 100% ( 6/6 )
Branches : 100% ( 0/0 )
Functions : 100% ( 2/2 )
Lines : 100% ( 6/6 )
================================================================================
===[ STDERR ]===================================================================
PASS Button/click.test.ts
√ button should click!

Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: XXs
Ran all test suites.
================================================================================
`;

exports[`Deep paths test should pass using template "with-typescript-2-7": lcov 1`] = `
"TN:
SF:<cwd>/src/Button/click.ts
FN:3,click
FNF:1
FNH:1
FNDA:1,click
DA:1,1
DA:3,1
DA:4,1
LF:3
LH:3
BRF:0
BRH:0
end_of_record
TN:
SF:<cwd>/src/Tests/Button/click.test.ts
FN:3,(anonymous_0)
FNF:1
FNH:1
FNDA:1,(anonymous_0)
DA:1,1
DA:3,1
DA:4,1
LF:3
LH:3
BRF:0
BRH:0
end_of_record
"
`;

exports[`Deep paths test should pass using template "with-typescript-2-7": output 1`] = `
√ npm -s run test
↳ exit code: 0
===[ STDOUT ]===================================================================
=============================== Coverage summary ===============================
Statements : 100% ( 6/6 )
Branches : 100% ( 0/0 )
Functions : 100% ( 2/2 )
Lines : 100% ( 6/6 )
================================================================================
===[ STDERR ]===================================================================
PASS Button/click.test.ts
√ button should click!

Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: XXs
Ran all test suites.
================================================================================
`;
20 changes: 20 additions & 0 deletions e2e/__tests__/deep-path.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { readFileSync } from 'fs'
import { join } from 'path'

import { allValidPackageSets } from '../__helpers__/templates'
import { configureTestCase } from '../__helpers__/test-case'

describe('Deep paths test', () => {
const testCase = configureTestCase('deep')

testCase.runWithTemplates(allValidPackageSets, 0, (runTest, { testLabel }) => {
it(testLabel, () => {
const result = runTest()
expect(result.status).toBe(0)
expect(result).toMatchSnapshot('output')
let content: string = readFileSync(join(result.cwd, 'src', 'Tests', 'coverage', 'lcov.info'), 'utf8')
content = result.normalize(content)
expect(content).toMatchSnapshot('lcov')
})
})
})