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

Commit

Permalink
add serverside testing (#139)
Browse files Browse the repository at this point in the history
* test app class

* jest config

* add exampleRouter test

* move package.json jest config to jest.config.js

* fix client tests

* run docker in ci

* no cli

* try -T flag

* oops i put it in the wrong place

* private

* remove sample env, update docs

* recreate packagelock

* fix import
  • Loading branch information
timmyichen authored and Zeko369 committed Dec 11, 2019
1 parent 4c9ef69 commit b77d3a0
Show file tree
Hide file tree
Showing 10 changed files with 1,243 additions and 322 deletions.
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
- CHAPTER_EMAIL=ourEmail@placeholder.place
- 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

0 comments on commit b77d3a0

Please sign in to comment.