Skip to content

Commit af0cb02

Browse files
author
Serhat Bolsu
committed
resource_file_ready
1 parent 29de625 commit af0cb02

File tree

18 files changed

+929
-46
lines changed

18 files changed

+929
-46
lines changed
File renamed without changes.

.eslintrc.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
module.exports = {
2+
'env': {
3+
'es6': true,
4+
'browser': true,
5+
'mocha': true,
6+
},
7+
'extends': [
8+
'google',
9+
"plugin:mocha/recommended"
10+
],
11+
'globals': {
12+
'Atomics': 'readonly',
13+
'SharedArrayBuffer': 'readonly',
14+
},
15+
'parserOptions': {
16+
'ecmaVersion': 2018,
17+
},
18+
'rules': {
19+
"arrow-parents": [0, "as-needed"],
20+
'quotes': [0, "double"],
21+
"require-jsdoc": "off",
22+
"brace-style": [0, "allman", { "allowSingleLine": true }],
23+
"max-len": ["error", { "code": 100 }],
24+
"object-curly-spacing": ["error", "always"],
25+
},
26+
'plugins': [
27+
"mocha",
28+
],
29+
};

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/node_modules/*
2-
.idea/*
2+
.idea/*
3+
.env

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# API Testing Sample Framework with Javascript
2+
3+
### Setup
4+
First need to create your own configurations.
5+
Copy the sample.env and rename to `.env`
6+
- change required variables
7+
8+
```npm install```
9+
10+
- Run tests in local
11+
12+
```npm test```
13+
14+
In case you want to run against sample api *Vegetables*,
15+
run the server with
16+
17+
```npm start```
18+

config/jest_environment.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const NodeEnvironment = require('jest-environment-node');
2+
require('dotenv').config();
3+
const fs = require('fs');
4+
5+
class JestEnvironment extends NodeEnvironment {
6+
constructor(config) {
7+
super(config);
8+
}
9+
10+
async setup() {
11+
await super.setup();
12+
this.global.baseUrl = process.env.BASE_URL;
13+
}
14+
15+
async teardown() {
16+
await super.teardown();
17+
}
18+
19+
runScript(script) {
20+
return super.runScript(script);
21+
}
22+
}
23+
24+
module.exports = JestEnvironment;

config/setup.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = async function() {
2+
console.log('beforeAll is running');
3+
global.myVal = '!!Value!!';
4+
};

config/teardown.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = async function() {
2+
console.log('afterAll is running');
3+
console.log(`global in teardown ${global.myVal}`);
4+
};

jest.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
testTimeout: 10000,
3+
testEnvironment: "./config/jest_environment.js",
4+
globalSetup: './config/setup.js',
5+
globalTeardown: './config/teardown.js',
6+
};

0 commit comments

Comments
 (0)