Skip to content

Commit db04507

Browse files
committed
Add mocha tests. Add checking for CodeceptJS 2 and 3.
1 parent 89b0959 commit db04507

19 files changed

+8376
-11
lines changed

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
node_modules
1+
node_modules
2+
output
3+
codeceptjs_check/v2/node_modules
4+
codeceptjs_check/v2/output
5+
codeceptjs_check/v3/node_modules
6+
codeceptjs_check/v3/output

.npmignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
__tests__
2+
output
3+
codeceptjs_check
4+
codecept.conf.js
5+
jsconfig.json

__tests__/test.db

12 KB
Binary file not shown.

__tests__/test.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const DbHelper = require( '..' );
2+
3+
describe( 'DbHelper', () => {
4+
5+
const helper = new DbHelper();
6+
7+
before( async () => {
8+
helper.connect( 'testdb', 'sqlite://./__tests__/test.db' );
9+
} );
10+
11+
after( async () => {
12+
helper.disconnect( 'testdb' );
13+
} );
14+
15+
it( 'can run query', async () => {
16+
const r = await helper.query( 'testdb', 'SELECT id, name, username, password FROM user' );
17+
console.table( r );
18+
} );
19+
20+
it( 'can run command', async () => {
21+
await helper.run( 'testdb', 'UPDATE user SET name = name WHERE id = 1' );
22+
} );
23+
24+
} );

codeceptjs_check/v2/codecept.conf.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const { setHeadlessWhen } = require('@codeceptjs/configure');
2+
3+
// turn on headless mode when running with HEADLESS=true environment variable
4+
// export HEADLESS=true && npx codeceptjs run
5+
setHeadlessWhen(process.env.HEADLESS);
6+
7+
exports.config = {
8+
tests: 'tests/*.js',
9+
output: './output',
10+
helpers: {
11+
CmdHelper: {
12+
require: '../../index.js'
13+
}
14+
},
15+
include: {
16+
I: './steps_file.js'
17+
},
18+
bootstrap: null,
19+
mocha: {},
20+
name: 'v2',
21+
plugins: {
22+
retryFailedStep: {
23+
enabled: true
24+
},
25+
screenshotOnFail: {
26+
enabled: true
27+
}
28+
}
29+
}

codeceptjs_check/v2/jsconfig.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"compilerOptions": {
3+
"allowJs": true
4+
}
5+
}

0 commit comments

Comments
 (0)