Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move test cmd #6

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 2 additions & 15 deletions buildspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,17 @@ phases:
runtime-versions:
nodejs: 10
commands:
# Setup for Yarn
- curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
- echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
# Do it!
- apt-get update -y
- apt-get install -y yarn
pre_build:
commands:
- echo Nothing to do in the pre_build phase...
- yarn install
- yarn test
build:
commands:
- echo Build started on `date`
- npm install
- npm test
post_build:
commands:
- echo Build completed on `date`
cache:
paths:
- 'node_modules/**/*'
artifacts:
files:
- package.json
- package-lock.json
- 'src/**/*'
- README.md
name: yourBuildName-$(date +%Y-%m-%d)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "",
"main": "index.js",
"scripts": {
"test": "jest --forceExit",
"test": "./node_modules/.bin/jest --forceExit",
"start": "node ./src/bin/www"
},
"keywords": [],
Expand Down
37 changes: 19 additions & 18 deletions src/test/auth.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@
* Basic tests for Auth system API
*/
//import chai-http to send requests to the app
const request = require("supertest");
const app = require("../app");
const request = require('supertest');
const app = require('../app');

describe("User registration", () => {
test("Should return 201 and confirmation for valid input", async done => {
describe('User registration', () => {
test('Should return 201 and confirmation for valid input', async done => {
//mock valid user input
const new_user = {
name: "John Wick",
email: "[email protected]",
password: "secret"
name: 'John Wick',
email: '[email protected]',
password: 'secret'
};
//send request to the app
try {
const res = await request(app)
.post("/register")
.post('/register')
.send(new_user);

expect(res.statusCode).toEqual(201);
expect(res.body.message).toEqual("User created!");
expect(res.body.message).toEqual('User created!');
expect(res.body.errors.length).toEqual(0);
done();
} catch (err) {
Expand All @@ -30,31 +30,32 @@ describe("User registration", () => {
});
});

describe("Protected route", () => {
test("should return 200 and user details if valid token provided", async done => {
describe('Protected route', () => {
test('should return 200 and user details if valid token provided', async done => {
//mock login to get token
const valid_input = {
email: "[email protected]",
password: "secret"
email: '[email protected]',
password: 'secret'
};
//send login request to the app to receive token
try {
const res = await request(app)
.post("/login")
.post('/login')
.send(valid_input);
const token = res.body.token;
console.log('token', token);
const protected_response = await request(app)
.get("/protected")
.set("Authorization", token);
.get('/protected')
.set('Authorization', token);
expect(protected_response.statusCode).toEqual(300);
expect(protected_response.body.message).toEqual(
"Welcome, your email is [email protected]"
'Welcome, your email is [email protected]'
);
expect(protected_response.body.user.email).toBeDefined();
expect(protected_response.body.errors.length).toEqual(0);
done();
} catch (err) {
console.log("@@@@@@@@", err.message);
console.log('@@@@@@@@', err.message);
}
});
});
10 changes: 0 additions & 10 deletions src/test/end.test.js

This file was deleted.

35 changes: 0 additions & 35 deletions src/test/test.js

This file was deleted.

Loading