-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
45 changed files
with
2,587 additions
and
146 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
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
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 |
---|---|---|
@@ -1,15 +1,9 @@ | ||
module.exports = { | ||
extends: ["../../.eslintrc.js"], | ||
globals: { | ||
__PATH_PREFIX__: true, | ||
allure: true, | ||
}, | ||
env: { | ||
browser: true, | ||
node: true, | ||
es6: true, | ||
jasmine: true, | ||
jest: true | ||
}, | ||
extends: [ | ||
"../../.eslintrc.js", | ||
], | ||
}; | ||
jest: true, | ||
} | ||
} |
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,47 +1,45 @@ | ||
# Allure integration for jest framework | ||
# allure-jest | ||
|
||
> **Warning** | ||
> This integration doesn't work with default runner since jest 27+. | ||
> To use this integration after jest 27 you need to change default runner to `Jasmine`. | ||
> If you are using `jest@<27.0.0` use [`allure-jasmine` package][allure-jasmine] | ||
> or consider to use `jest-circus` as a test runner with this package. | ||
> | ||
> The integration doesn't work with custom runners. If you want to use the | ||
> integration use `jest-circus` as a test runner. | ||
## Examples | ||
## Installation | ||
|
||
You can find example setup and usage in this [repo](https://github.com/vovsemenv/allure-jest-example) | ||
Use your favorite node package manager to install required packages: | ||
|
||
## Circus test runner (default for jest@^27) | ||
|
||
Currently, we don't have official solution for circus test runner. Consider using this [community plugin](https://github.com/ryparker/jest-circus-allure-environment) instead | ||
```shell | ||
npm add -D allure-jest allure-js-commons | ||
``` | ||
|
||
## Jasmine test runner (default for jest@<27) | ||
Then, add following line to your `jest.config.js` file: | ||
|
||
### Install dependencies | ||
```diff | ||
/** @type {import('jest').Config} */ | ||
const config = { | ||
+ testEnvironment: "allure-jest", | ||
} | ||
|
||
```bash | ||
npm i -D jest-jasmine2@INSTALLED_JEST_VERSION allure-jasmine allure-js-commons @types/jasmine | ||
module.exports = config | ||
``` | ||
|
||
Create `allure-setup.ts` file: | ||
|
||
```typescript | ||
import { JasmineAllureReporter } from "allure-jasmine"; | ||
import { JasmineAllureInterface } from "allure-jasmine/dist/src/JasmineAllureReporter"; | ||
## Use Allure runtime Api | ||
|
||
const reporter = new JasmineAllureReporter({ resultsDir: "allure-results" }); | ||
jasmine.getEnv().addReporter(reporter); | ||
// @ts-expect-error | ||
global.allure = reporter.getInterface(); | ||
The plugin provides custom global commands which allow to add additional info | ||
inside your tests: | ||
|
||
declare global { | ||
const allure: JasmineAllureInterface; | ||
} | ||
```javascript | ||
it("my test", () => { | ||
allure.attachment(currentTest.id(), screenshot, "image/png"); | ||
allure.epic(currentTest.id(), "my_epic"); | ||
allure.parameter(currentTest.id(), "parameter_name", "parameter_value", { | ||
mode: "hidden", | ||
excluded: false, | ||
}); | ||
}); | ||
``` | ||
|
||
### Change jest.config.js | ||
|
||
```js | ||
module.exports = { | ||
testRunner: "jest-jasmine2", | ||
preset: "ts-jest", | ||
setupFilesAfterEnv: ["./allure-setup.ts"], | ||
}; | ||
``` | ||
[allure-jasmine]: https://github.com/allure-framework/allure-js/tree/master/packages/allure-jasmine |
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,39 +1,92 @@ | ||
{ | ||
"private": true, | ||
"name": "allure-jest", | ||
"version": "2.5.0", | ||
"description": "Allure Jest integration", | ||
"license": "Apache-2.0", | ||
"packageManager": "[email protected]", | ||
"author": { | ||
"name": "Qameta Software", | ||
"email": "[email protected]", | ||
"url": "https://qameta.io/" | ||
}, | ||
"keywords": [ | ||
"jest", | ||
"circus", | ||
"typescript", | ||
"allure" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/allure-framework/allure-js.git", | ||
"directory": "packages/allure-jest" | ||
}, | ||
"main": "./dist/index.js", | ||
"types": "./dist/index.d.ts", | ||
"files": [ | ||
"dist" | ||
], | ||
"scripts": { | ||
"clean": "rimraf ./dist ./out", | ||
"lint": "eslint ./test --ext .ts", | ||
"lint:fix": "eslint ./test --ext .ts --fix", | ||
"compile": "tsc", | ||
"generate-report": "allure generate ./out/allure-results -o ./out/allure-report --clean", | ||
"jasmineTest": "jest --config ./test/default-runner/jest.config.js", | ||
"test": "rimraf ./out; yarn run jasmineTest" | ||
"test": "nyc tsx --tsconfig ./tsconfig.json ./test/runner.ts", | ||
"coverage": "codecov", | ||
"lint": "eslint ./src --ext .ts", | ||
"lint:fix": "eslint ./src --ext .ts --fix" | ||
}, | ||
"nyc": { | ||
"check-coverage": false, | ||
"lines": 80, | ||
"statements": 80, | ||
"functions": 75, | ||
"branches": 70, | ||
"extension": [ | ||
".ts" | ||
], | ||
"exclude": [ | ||
"test/**/*.*", | ||
"**/*.d.ts" | ||
], | ||
"reporter": [ | ||
"lcov", | ||
"text" | ||
], | ||
"all": true, | ||
"report-dir": "./out/coverage", | ||
"temp-dir": "./out/.nyc" | ||
}, | ||
"devDependencies": { | ||
"@jest/core": "^29.6.2", | ||
"@jest/environment": "^29.6.2", | ||
"@jest/types": "^29.6.1", | ||
"@types/chai": "^4.3.5", | ||
"@types/chai-like": "^1.1.1", | ||
"@types/chai-things": "^0.0.35", | ||
"@types/glob": "^8.1.0", | ||
"@types/jasmine": "^3.3.12", | ||
"@types/jest": "^26.0.10", | ||
"allure-jasmine": "workspace:*", | ||
"jest": "^26.4.2", | ||
"@types/jest": "^29.5.3", | ||
"@types/mocha": "^10.0.1", | ||
"@types/node": "^16.7.8", | ||
"@types/sinon": "^10.0.16", | ||
"@types/source-map-support": "^0", | ||
"chai": "^4.3.7", | ||
"chai-like": "^1.1.1", | ||
"chai-things": "^0.2.0", | ||
"codecov": "^3.8.3", | ||
"glob": "^7.1.7", | ||
"jest-cli": "^29.6.2", | ||
"mocha": "^10.2.0", | ||
"mocha-multi-reporters": "^1.5.1", | ||
"nyc": "^15.1.0", | ||
"rimraf": "^3.0.2", | ||
"typescript": "^4.4.2" | ||
"sinon": "^15.2.0", | ||
"source-map-support": "^0.5.21", | ||
"tsx": "^3.12.7", | ||
"typescript": "^5.1.3" | ||
}, | ||
"dependencies": { | ||
"allure-js-commons": "workspace:*" | ||
"@jest/expect": "^29.6.2", | ||
"allure-js-commons": "workspace:*", | ||
"jest-circus": "^29.6.2", | ||
"jest-environment-node": "^29.6.2" | ||
} | ||
} |
Oops, something went wrong.