|
1 | 1 | const { action } = require('../../..')
|
2 | 2 | const assert = require('assert')
|
| 3 | +const expect = require('expect') |
3 | 4 | const fs = require('fs')
|
4 | 5 | const glob = require('glob')
|
5 | 6 | const { execFileSync } = require('child_process')
|
6 | 7 |
|
7 |
| -action('Run test (it should fail)', async () => { |
8 |
| - let failed = false |
| 8 | +action('Clean the results directory', async () => { |
9 | 9 | execFileSync('rm', ['-rf', 'tmp/issue27-allure-results'])
|
10 |
| - try { |
11 |
| - execFileSync( |
12 |
| - './bin/prescript', |
13 |
| - [require.resolve('../fixtures/Issue27-AnsiColorTestFixture.js')], |
14 |
| - { |
15 |
| - env: { |
16 |
| - ...process.env, |
17 |
| - ALLURE_RESULTS_DIR: 'tmp/issue27-allure-results', |
18 |
| - ALLURE_SUITE_NAME: 'prescript-regression-issue27', |
19 |
| - FORCE_COLOR: '1' |
20 |
| - } |
21 |
| - } |
22 |
| - ) |
23 |
| - } catch (error) { |
24 |
| - failed = true |
25 |
| - } |
26 |
| - assert(failed, 'Expected prescript command to fail') |
27 | 10 | })
|
28 | 11 |
|
| 12 | +for (let i = 1; i <= 3; i++) { |
| 13 | + action('Run test (it should fail)', async () => { |
| 14 | + let failed = false |
| 15 | + try { |
| 16 | + execFileSync( |
| 17 | + './bin/prescript', |
| 18 | + [require.resolve('../fixtures/Issue27-AnsiColorTestFixture.js')], |
| 19 | + { |
| 20 | + env: { |
| 21 | + ...process.env, |
| 22 | + ALLURE_RESULTS_DIR: 'tmp/issue27-allure-results', |
| 23 | + ALLURE_SUITE_NAME: 'prescript-regression-issue27', |
| 24 | + FORCE_COLOR: '1' |
| 25 | + } |
| 26 | + } |
| 27 | + ) |
| 28 | + } catch (error) { |
| 29 | + failed = true |
| 30 | + } |
| 31 | + assert(failed, 'Expected prescript command to fail') |
| 32 | + }) |
| 33 | +} |
| 34 | + |
29 | 35 | action('Verify that there are JSON allure results generated', async () => {
|
30 | 36 | const files = glob.sync('*.json', { cwd: 'tmp/issue27-allure-results' })
|
31 |
| - assert(files.length > 0, 'Expected to file JSON files') |
| 37 | + assert(files.length > 0, 'Expected to find JSON files') |
| 38 | +}) |
| 39 | + |
| 40 | +action('Verify the test results JSON have consistent historyId', async () => { |
| 41 | + const files = glob.sync('*-result.json', { |
| 42 | + cwd: 'tmp/issue27-allure-results' |
| 43 | + }) |
| 44 | + const historyIds = Array.from( |
| 45 | + new Set( |
| 46 | + files.map( |
| 47 | + f => |
| 48 | + JSON.parse(fs.readFileSync(`tmp/issue27-allure-results/${f}`, 'utf8')) |
| 49 | + .historyId |
| 50 | + ) |
| 51 | + ) |
| 52 | + ) |
| 53 | + expect(historyIds).toHaveLength(1) |
32 | 54 | })
|
33 | 55 |
|
34 | 56 | action('Generate an allure-report', async () => {
|
|
0 commit comments