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

Commit

Permalink
feat(package.json): renamed npm package, better declarations, removed…
Browse files Browse the repository at this point in the history
… logs
  • Loading branch information
ryparker committed Jul 6, 2020
1 parent d69ad2d commit 0d2cae0
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 257 deletions.
188 changes: 0 additions & 188 deletions jest.config.js

This file was deleted.

41 changes: 31 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
{
"name": "jest-circus-allure-reporter",
"name": "jest-circus-allure-environment",
"version": "0.0.2",
"repository": "https://ryparker@github.com/ryparker/jest-circus-allure-reporter.git",
"repository": "https://ryparker@github.com/ryparker/jest-circus-allure-environment.git",
"author": "Ryan Parker <ryan.parker3@outlook.com>",
"license": "MIT",
"files": [
"dist"
],
"main": "dist/index",
"types": "dist/index.d.ts",
"main": "./dist",
"scripts": {
"build": "rimraf dist && tsc",
"test": "rimraf allure-results && yarn build && jest",
"lint": "xo src",
"fix": "xo src --fix"
},
"jest": {
"testEnvironment": "./dist",
"testRunner": "jest-circus/runner"
},
"xo": {
"globals": [
"allure"
Expand All @@ -26,24 +29,31 @@
"plugin:jest/recommended"
]
},
"release": {
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
"@semantic-release/git",
"@semantic-release/github",
"@semantic-release/npm"
]
},
"dependencies": {
"@jest/environment": "^26.1.0",
"@jest/reporters": "^26.1.0",
"@jest/types": "^26.1.0",
"allure-js-commons": "^2.0.0-beta.7",
"crypto": "^1.0.1",
"jest-circus": "^26.1.0",
"jest-docblock": "^26.0.0",
"jest-environment-node": "^26.1.0",
"lodash": "^4.17.15",
"prettier": "^2.0.5",
"pretty-format": "^26.1.0",
"strip-ansi": "^6.0.0"
},
"devDependencies": {
"@types/allure-js-commons": "^0.0.1",
"@types/jest": "^26.0.3",
"@types/lodash": "^4.14.157",
"@types/node": "^14.0.14",
"commitizen": "^4.1.2",
"cz-conventional-changelog": "^3.2.0",
Expand All @@ -54,12 +64,23 @@
"typescript": "^3.9.6",
"xo": "^0.32.1"
},
"engines": {
"node": ">=12.x"
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
},
"engines": {
"node": ">=12.x"
}
"keywords": [
"jest",
"circus",
"reporter",
"allure",
"environment",
"detailed",
"reports",
"collect",
"analyze"
]
}
30 changes: 13 additions & 17 deletions src/circus-environment.ts → src/allure-node-environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,8 @@ import NodeEnvironment from 'jest-environment-node';
import type {EnvironmentContext} from '@jest/environment';
import AllureReporter from './allure-reporter';
import {AllureRuntime, IAllureConfig} from 'allure-js-commons';
// Import type JestAllureInterface from './allure-interface';

// export interface Global extends NodeJS.Global {
// allure: JestAllureInterface;
// }

// declare global {
// namespace NodeJS {
// interface Global {
// allure: JestAllureInterface;
// }
// }
// }
export default class CircusEnvironment extends NodeEnvironment {
export default class AllureNodeEnvironment extends NodeEnvironment {
private readonly reporter: AllureReporter;
private readonly testPath: string;
private readonly docblockPragmas?: Record<string, string | string[]>;
Expand All @@ -29,23 +17,32 @@ export default class CircusEnvironment extends NodeEnvironment {
this.docblockPragmas = context.docblockPragmas;
this.testPath = context.testPath ? context.testPath.replace(config.rootDir, '') : '';

if (this.testPath.includes('tests/')) {
this.testPath = this.testPath.split('tests/')[1];
}

if (this.testPath.includes('__tests__/')) {
this.testPath = this.testPath.split('__tests__/')[1];
}

this.reporter = new AllureReporter(new AllureRuntime(allureConfig));

this.global.allure = this.reporter.getImplementation();
console.log(' this.docblockPragmas:', this.docblockPragmas);
}

async setup() {
await super.setup();

this.global.allure = this.reporter.getImplementation();
}

async teardown() {
this.global.allure = null;

await super.teardown();
}

handleTestEvent(event: Circus.Event, state: Circus.State) {
console.log(`Event: ${event.name}`);
// Console.log(`Event: ${event.name}`);
switch (event.name) {
case 'setup':
break;
Expand Down Expand Up @@ -80,7 +77,6 @@ export default class CircusEnvironment extends NodeEnvironment {
this.reporter.endHook(event.error ?? event.hook.asyncError);
break;
case 'test_fn_start':
console.log('this.testPath:', this.testPath);
this.reporter.startCase(event.test, state, this.testPath);
break;
case 'test_fn_success':
Expand Down
6 changes: 5 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
export {default} from './circus-environment';
export {default} from './allure-node-environment';

import AllureNodeEnvironment from './allure-node-environment';
module.exports = AllureNodeEnvironment;

3 changes: 1 addition & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@
"moduleResolution": "node",
"declaration": true,
"sourceMap": true,
"isolatedModules": true,
"importsNotUsedAsValues": "error",
"noImplicitReturns": true,
"strict": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"types": ["node", "jest", "allure-js-commons", "lodash"],
"types": ["node", "jest", "allure-js-commons"],
"outDir": "dist/"
},
"include": ["src/**/*"],
Expand Down
Loading

0 comments on commit 0d2cae0

Please sign in to comment.