Skip to content
This repository has been archived by the owner on Aug 28, 2022. It is now read-only.

Commit

Permalink
fix(xo): xO linter fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ryparker committed Dec 23, 2020
1 parent 77601cf commit 774fd4f
Show file tree
Hide file tree
Showing 5 changed files with 621 additions and 556 deletions.
16 changes: 8 additions & 8 deletions package.json
Expand Up @@ -80,7 +80,7 @@
"jest-docblock": "^26.0.0",
"jest-environment-node": "^26.6.2",
"lodash": "^4.17.20",
"prettier": "^2.2.0",
"prettier": "^2.2.1",
"pretty-format": "^26.6.2",
"strip-ansi": "^6.0.0"
},
Expand All @@ -89,20 +89,20 @@
"@semantic-release/git": "^9.0.0",
"@types/allure-js-commons": "^0.0.1",
"@types/highlight.js": "^10.1.0",
"@types/jest": "^26.0.15",
"@types/jest": "^26.0.19",
"@types/lodash": "^4.14.165",
"@types/node": "^14.14.9",
"@types/node": "^14.14.14",
"commitizen": "^4.2.2",
"conventional-changelog-conventionalcommits": "^4.5.0",
"cz-conventional-changelog": "3.3.0",
"eslint-config-xo-typescript": "^0.36.0",
"eslint-config-xo-typescript": "^0.37.0",
"eslint-plugin-jest": "^24.1.3",
"husky": "^4.3.0",
"husky": "^4.3.6",
"jest": "^26.6.3",
"lint-staged": "^10.5.2",
"lint-staged": "^10.5.3",
"semantic-release": "^17.3.0",
"typescript": "^4.1.2",
"xo": "^0.35.0"
"typescript": "^4.1.3",
"xo": "^0.36.1"
},
"engines": {
"node": ">=12.x"
Expand Down
38 changes: 24 additions & 14 deletions src/allure-node-environment.ts
Expand Up @@ -5,10 +5,12 @@ import AllureReporter from './allure-reporter';
import type {EnvironmentContext} from '@jest/environment';

import NodeEnvironment = require('jest-environment-node');
import {basename} from 'path';

export default class AllureNodeEnvironment extends NodeEnvironment {
private readonly reporter: AllureReporter;
private readonly testPath: string;
private readonly testFileName: string;
private readonly docblockPragmas?: Record<string, string | string[]>;

constructor(config: Config.ProjectConfig, context: EnvironmentContext) {
Expand All @@ -28,6 +30,8 @@ export default class AllureNodeEnvironment extends NodeEnvironment {
this.testPath = this.testPath.split('__tests__/')[1];
}

this.testFileName = basename(this.testPath);

this.docblockPragmas = context.docblockPragmas;

this.reporter = new AllureReporter({
Expand All @@ -51,26 +55,29 @@ export default class AllureNodeEnvironment extends NodeEnvironment {

handleTestEvent(event: Circus.Event, state: Circus.State) {
// Console.log(`Event: ${event.name}`);
// console.log({event});
// Console.log({event});

switch (event.name) {
case 'setup':

break;
case 'add_hook':
break;
case 'add_test':
break;
case 'run_start':
/**
* @privateRemarks
* This is called at the start of a test run.
*/
this.reporter.startTestFile(this.testFileName);

break;
case 'test_skip':
this.reporter.pendingTestCase(event.test, state, this.testPath);
this.reporter.startTestCase(event.test, state, this.testPath);
this.reporter.pendingTestCase(event.test);

break;
case 'test_todo':
this.reporter.pendingTestCase(event.test, state, this.testPath);
this.reporter.startTestCase(event.test, state, this.testPath);
this.reporter.pendingTestCase(event.test);

break;
case 'start_describe_definition':
/**
Expand Down Expand Up @@ -104,7 +111,7 @@ export default class AllureNodeEnvironment extends NodeEnvironment {
* hook as part of the "test body" instead of the "Set up".
*/

// This.reporter.startCase(event.test, state, this.testPath);
// This.reporter.startTestCase(event.test, state, this.testPath);
break;
case 'hook_start':
this.reporter.startHook(event.hook.type);
Expand All @@ -127,18 +134,19 @@ export default class AllureNodeEnvironment extends NodeEnvironment {
* "Test body" execution.
*/

this.reporter.startCase(event.test, state, this.testPath);
this.reporter.startTestCase(event.test, state, this.testPath);

break;
case 'test_fn_success':
this.reporter.passTestCase(event.test, state, this.testPath);
if (event.test.errors.length > 0) {
this.reporter.failTestCase(event.test.errors[0]);
} else {
this.reporter.passTestCase();
}

break;
case 'test_fn_failure':
// Console.log('TEST_FN_FAILURE ERROR:', event.error);
// console.log('TEST_FN_FAILURE TEST.ERRORS:', event.test.errors);
// console.log('TEST_FN_FAILURE TEST.ASYNCERROR:', event.test.asyncError);
this.reporter.failTestCase(event.test, state, this.testPath, event.test.errors[0]);
this.reporter.failTestCase(event.test.errors[0]);

break;
case 'test_done':
Expand Down Expand Up @@ -182,6 +190,8 @@ export default class AllureNodeEnvironment extends NodeEnvironment {

break;
case 'run_finish':
this.reporter.endTestFile();

break;
case 'teardown':
break;
Expand Down

0 comments on commit 774fd4f

Please sign in to comment.