|
1 | 1 | const { DOWN, ENTER } = require('inquirer-test');
|
2 | 2 | const run = require('inquirer-test');
|
3 | 3 | const path = require('path');
|
| 4 | +const fs = require('fs'); |
| 5 | +const mkdirp = require('mkdirp'); |
4 | 6 |
|
5 | 7 | const runner = path.join(__dirname, '../../bin/codecept.js');
|
| 8 | +const codecept_dir = path.join(__dirname, '/../data/sandbox/configs/init'); |
6 | 9 |
|
7 | 10 | describe('Init Command', function () {
|
8 | 11 | this.timeout(20000);
|
9 | 12 |
|
10 |
| - it('steps are showing', async () => { |
11 |
| - const result = await run([runner, 'init'], ['Y', ENTER, ENTER, DOWN, DOWN, DOWN, ENTER, 'y']); |
| 13 | + beforeEach(() => { |
| 14 | + mkdirp.sync(codecept_dir); |
| 15 | + process.env._INIT_DRY_RUN_INSTALL = true; |
| 16 | + }); |
| 17 | + |
| 18 | + afterEach(() => { |
| 19 | + try { |
| 20 | + fs.unlinkSync(`${codecept_dir}/codecept.conf.ts`); |
| 21 | + fs.unlinkSync(`${codecept_dir}/steps_file.ts`); |
| 22 | + fs.unlinkSync(`${codecept_dir}/tsconfig.json`); |
| 23 | + } catch (e) { |
| 24 | + // continue regardless of error |
| 25 | + } |
| 26 | + |
| 27 | + try { |
| 28 | + fs.unlinkSync(`${codecept_dir}/codecept.conf.js`); |
| 29 | + fs.unlinkSync(`${codecept_dir}/steps_file.js`); |
| 30 | + fs.unlinkSync(`${codecept_dir}/jsconfig.json`); |
| 31 | + } catch (e) { |
| 32 | + // continue regardless of error |
| 33 | + } |
| 34 | + |
| 35 | + delete process.env._INIT_DRY_RUN_INSTALL; |
| 36 | + }); |
| 37 | + |
| 38 | + it('should init Codecept with TypeScript REST JSONResponse English', async () => { |
| 39 | + const result = await run([runner, 'init', codecept_dir], ['Y', ENTER, ENTER, DOWN, DOWN, DOWN, ENTER, 'y', ENTER, codecept_dir, ENTER, ENTER, ENTER, ENTER]); |
| 40 | + |
12 | 41 | result.should.include('Welcome to CodeceptJS initialization tool');
|
13 | 42 | result.should.include('It will prepare and configure a test environment for you');
|
14 | 43 | result.should.include('Installing to');
|
15 | 44 | result.should.include('? Do you plan to write tests in TypeScript? (y/N)');
|
16 | 45 | result.should.include('Where are your tests located? ./*_test.ts');
|
17 | 46 | result.should.include('What helpers do you want to use? REST');
|
18 | 47 | result.should.include('? Do you want to use JSONResponse helper for assertions on JSON responses?');
|
| 48 | + result.should.include('? Where should logs, screenshots, and reports to be stored?'); |
| 49 | + result.should.include('? Do you want to enable localization for tests?'); |
| 50 | + |
| 51 | + const config = fs.readFileSync(`${codecept_dir}/codecept.conf.ts`).toString(); |
| 52 | + config.should.include('I: \'./steps_file\''); |
| 53 | + |
| 54 | + fs.accessSync(`${codecept_dir}/steps_file.ts`, fs.constants.R_OK); |
| 55 | + fs.accessSync(`${codecept_dir}/tsconfig.json`, fs.constants.R_OK); |
| 56 | + }); |
| 57 | + |
| 58 | + it('should init Codecept with JavaScript REST JSONResponse de-DE', async () => { |
| 59 | + const result = await run([runner, 'init', codecept_dir], [ENTER, ENTER, DOWN, DOWN, DOWN, ENTER, 'y', ENTER, codecept_dir, ENTER, DOWN, ENTER, ENTER, ENTER]); |
| 60 | + |
| 61 | + result.should.include('Welcome to CodeceptJS initialization tool'); |
| 62 | + result.should.include('It will prepare and configure a test environment for you'); |
| 63 | + result.should.include('Installing to'); |
| 64 | + result.should.include('? Do you plan to write tests in TypeScript? (y/N)'); |
| 65 | + result.should.include('Where are your tests located? ./*_test.js'); |
| 66 | + result.should.include('What helpers do you want to use? REST'); |
| 67 | + result.should.include('? Do you want to use JSONResponse helper for assertions on JSON responses?'); |
| 68 | + result.should.include('? Where should logs, screenshots, and reports to be stored?'); |
| 69 | + result.should.include('? Do you want to enable localization for tests?'); |
| 70 | + result.should.include('de-DE'); |
| 71 | + |
| 72 | + const config = fs.readFileSync(`${codecept_dir}/codecept.conf.js`).toString(); |
| 73 | + config.should.include('Ich: \'./steps_file.js\''); |
| 74 | + |
| 75 | + fs.accessSync(`${codecept_dir}/steps_file.js`, fs.constants.R_OK); |
| 76 | + fs.accessSync(`${codecept_dir}/jsconfig.json`, fs.constants.R_OK); |
19 | 77 | });
|
20 | 78 | });
|
0 commit comments