Skip to content
This repository has been archived by the owner on Jun 9, 2023. It is now read-only.

add serverside testing #139

Merged
merged 15 commits into from
Dec 11, 2019
Merged
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
4 changes: 3 additions & 1 deletion .github/workflows/ci-workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ jobs:
run: npm run lint
- name: Build next.js
run: npm run next:build
- name: Start docker service
run: docker-compose up -d
- name: Run tests
run: npm run test
run: npm run test:ci
env:
NODE_ENV: development
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ Install dependencies:
npm install
```

Setup Environment Variables:
Copy and paste env.sample into your .env file
If needed, set up environment variables under 'app -> environment' in the `docker-compose.yml` file.

Ensure that Docker Desktop is up and running, then run the following command:
```
Expand Down
4 changes: 4 additions & 0 deletions client/components/SomeComponent/__test__/Index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* @jest-environment jsdom
*/

import React from 'react';
import { render } from '@testing-library/react';
import { ThemeProvider } from 'styled-components';
Expand Down
4 changes: 4 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ services:
- DB_PASSWORD=password
- DB_NAME=chapter
- DB_URL=db
- [email protected]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Env variables will grow in the future, shouldn't we maintain separate .env

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the most part, there's no functional difference between having a long list of env variables in the docker-compose file and a long list of env variables in .env. With a separate .env file, you are requiring people to copy/rename a file before running it whereas this will be set up when you run docker-compose up.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the sake of simplicity I think that for now we should stick with env vars in docker-compose, but maybe later when we have a lot of them we could extract them.

- EMAIL_USERNAME=emailUsernamePlaceholder
- EMAIL_PASSWORD=emailPasswordPlaceholder
- EMAIL_SERVICE=emailServicePlaceholder
volumes:
- .:/usr/chapter
ports:
Expand Down
4 changes: 0 additions & 4 deletions env.sample

This file was deleted.

20 changes: 20 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
roots: ['<rootDir>'],
transform: {
'^.+\\.tsx?$': 'babel-jest',
},
moduleDirectories: ['node_modules', 'server'],
moduleNameMapper: {
'^server/(.*)': '<rootDir>/server/$1',
},
globals: {
'ts-jest': {
diagnostics: false,
},
},
watchPathIgnorePatterns: ['/node_modules'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
testMatch: ['/**/*.test.(ts|js|tsx|jsx)'],
};
Loading