Skip to content

Commit

Permalink
style: use prettier, relax tslint
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Homola committed Feb 15, 2018
1 parent 6335074 commit 61c3e07
Show file tree
Hide file tree
Showing 5 changed files with 170 additions and 98 deletions.
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"trailingComma": "all"
}
138 changes: 74 additions & 64 deletions src/__tests__/trx-generator.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import "jest";
import xml2js = require("xml2js");
import { generateTrx } from "../trx-generator";
import { JestTestRunResult } from "../types";
import xml2js = require("xml2js");

describe("trx-generator", (): void => {
it("processes the results correctly", (done): void => {
Expand Down Expand Up @@ -42,9 +42,9 @@ describe("trx-generator", (): void => {
numPassingAsserts: 1,
status: "failed",
title: "works not so well",
}
]
}
},
],
},
],
};
const result: string = generateTrx(input);
Expand All @@ -53,14 +53,24 @@ describe("trx-generator", (): void => {
expect(parsed).toBeTruthy();
expect(parsed.TestRun).toBeTruthy();
expect(parsed.TestRun.$).toBeTruthy();
expect(parsed.TestRun.$.xmlns).toEqual("http://microsoft.com/schemas/VisualStudio/TeamTest/2010");
expect(parsed.TestRun.$.xmlns).toEqual(
"http://microsoft.com/schemas/VisualStudio/TeamTest/2010",
);
expect(parsed.TestRun.Results).toBeTruthy();
expect(parsed.TestRun.Results.length).toEqual(1);
expect(parsed.TestRun.Results[0].UnitTestResult.length).toEqual(2);
expect(parsed.TestRun.Results[0].UnitTestResult[0].$.outcome).toEqual("Passed");
expect(parsed.TestRun.Results[0].UnitTestResult[0].$.duration).toEqual("00:00:03.500");
expect(parsed.TestRun.Results[0].UnitTestResult[1].$.outcome).toEqual("Failed");
expect(parsed.TestRun.Results[0].UnitTestResult[1].$.duration).toEqual("00:00:03.500");
expect(parsed.TestRun.Results[0].UnitTestResult[0].$.outcome).toEqual(
"Passed",
);
expect(parsed.TestRun.Results[0].UnitTestResult[0].$.duration).toEqual(
"00:00:03.500",
);
expect(parsed.TestRun.Results[0].UnitTestResult[1].$.outcome).toEqual(
"Failed",
);
expect(parsed.TestRun.Results[0].UnitTestResult[1].$.duration).toEqual(
"00:00:03.500",
);

done();
});
Expand Down Expand Up @@ -104,9 +114,9 @@ describe("trx-generator", (): void => {
numPassingAsserts: 1,
status: "failed",
title: "works not so well",
}
]
}
},
],
},
],
};
const result: string = generateTrx(input);
Expand All @@ -115,65 +125,65 @@ describe("trx-generator", (): void => {

it("handles skipped test suites", (): void => {
const input: JestTestRunResult = {
"numFailedTestSuites": 0,
"numFailedTests": 0,
"numPassedTestSuites": 0,
"numPassedTests": 0,
"numPendingTestSuites": 1,
"numPendingTests": 1,
"numRuntimeErrorTestSuites": 0,
"numTotalTestSuites": 1,
"numTotalTests": 1,
"snapshot": {
"added": 0,
"didUpdate": false,
"failure": false,
"filesAdded": 0,
"filesRemoved": 0,
"filesUnmatched": 0,
"filesUpdated": 0,
"matched": 0,
"total": 0,
"unchecked": 0,
"unmatched": 0,
"updated": 0
numFailedTestSuites: 0,
numFailedTests: 0,
numPassedTestSuites: 0,
numPassedTests: 0,
numPendingTestSuites: 1,
numPendingTests: 1,
numRuntimeErrorTestSuites: 0,
numTotalTestSuites: 1,
numTotalTests: 1,
snapshot: {
added: 0,
didUpdate: false,
failure: false,
filesAdded: 0,
filesRemoved: 0,
filesUnmatched: 0,
filesUpdated: 0,
matched: 0,
total: 0,
unchecked: 0,
unmatched: 0,
updated: 0,
},
"startTime": 1511376995239,
"success": true,
"testResults": [
startTime: 1511376995239,
success: true,
testResults: [
{
"numFailingTests": 0,
"numPassingTests": 0,
"numPendingTests": 1,
"perfStats": {
"end": 1511376996104,
"start": 1511376995923
numFailingTests: 0,
numPassingTests: 0,
numPendingTests: 1,
perfStats: {
end: 1511376996104,
start: 1511376995923,
},
"snapshot": {
"added": 0,
"fileDeleted": false,
"matched": 0,
"unchecked": 0,
"unmatched": 0,
"updated": 0
snapshot: {
added: 0,
fileDeleted: false,
matched: 0,
unchecked: 0,
unmatched: 0,
updated: 0,
},
"testFilePath": "C:\\Users\\Github\\test\\test.spec.js",
"testResults": [
testFilePath: "C:\\Users\\Github\\test\\test.spec.js",
testResults: [
{
"ancestorTitles": [],
"duration": 0,
"failureMessages": [],
"fullName": "first",
"numPassingAsserts": 0,
"status": "pending",
"title": "first"
}
ancestorTitles: [],
duration: 0,
failureMessages: [],
fullName: "first",
numPassingAsserts: 0,
status: "pending",
title: "first",
},
],
"sourceMaps": {},
"skipped": true
}
sourceMaps: {},
skipped: true,
},
],
"wasInterrupted": false
wasInterrupted: false,
};
const result: string = generateTrx(input);
expect(result).toBeTruthy();
Expand Down
14 changes: 10 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { writeFileSync } from "fs";

import { generateTrx } from "./trx-generator";
import { JestTestResult, JestTestRunResult, JestTestSuiteResult } from "./types";
import {
JestTestResult,
JestTestRunResult,
JestTestSuiteResult,
} from "./types";

/**
* All the configuration options.
Expand All @@ -14,9 +18,11 @@ interface IOptions {
outputFile: string;
}

const processor = (options: IOptions = {
outputFile: "test-results.trx",
}) => (testRunResult: JestTestRunResult): JestTestRunResult => {
const processor = (
options: IOptions = {
outputFile: "test-results.trx",
},
) => (testRunResult: JestTestRunResult): JestTestRunResult => {
process.stdout.write("Generating TRX file...");

const trx = generateTrx(testRunResult);
Expand Down
Loading

0 comments on commit 61c3e07

Please sign in to comment.