-
-
Notifications
You must be signed in to change notification settings - Fork 750
Expand file tree
/
Copy pathcustom-reporter-plugin_test.js
More file actions
47 lines (40 loc) · 1.83 KB
/
custom-reporter-plugin_test.js
File metadata and controls
47 lines (40 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import * as chai from 'chai';
chai.should();
import { expect } from 'expect';
import { exec } from 'child_process';
import { codecept_dir, codecept_run } from './consts.js';
import debugFactory from 'debug';
const debug = debugFactory('codeceptjs:tests');
import path from 'path';
import fs from 'fs';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const config_run_config = (config, grep, verbose = false) => `${codecept_run} ${verbose ? '--verbose' : ''} --config ${codecept_dir}/configs/custom-reporter-plugin/${config} ${grep ? `--grep "${grep}"` : ''}`
describe('CodeceptJS custom-reporter-plugin', function () {
this.timeout(10000)
it('should run custom-reporter-plugin test', done => {
exec(config_run_config('codecept.conf.js'), (err, stdout) => {
debug(stdout)
// Check for custom reporter output messages
expect(stdout).toContain('Hook Finished:')
expect(stdout).toContain('Test Started:')
expect(stdout).toContain('Test Failed:')
expect(stdout).toContain('Test Finished:')
expect(stdout).toContain('All tests completed')
expect(stdout).toContain('Total:')
expect(stdout).toContain('Passed:')
// Check if result file exists and has content
const resultFile = path.join(`${codecept_dir}/configs/custom-reporter-plugin`, 'output', 'result.json')
expect(fs.existsSync(resultFile)).toBe(true)
const resultContent = JSON.parse(fs.readFileSync(resultFile, 'utf8'))
expect(resultContent).toBeTruthy()
expect(resultContent).toHaveProperty('stats')
expect(resultContent.stats).toHaveProperty('tests')
expect(resultContent.stats).toHaveProperty('passes')
expect(resultContent.stats).toHaveProperty('failures')
expect(err).toBeTruthy()
done()
})
})
})