Skip to content

Commit 8a3c677

Browse files
committed
set up test
1 parent 64b9d06 commit 8a3c677

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+29648
-5563
lines changed

.eslintrc.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"root": true,
3+
"ignorePatterns": ["**/*"],
4+
"plugins": ["@nrwl/nx"],
5+
"overrides": [
6+
{
7+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
8+
"rules": {
9+
"@nrwl/nx/enforce-module-boundaries": [
10+
"error",
11+
{
12+
"enforceBuildableLibDependency": true,
13+
"allow": [],
14+
"depConstraints": [
15+
{
16+
"sourceTag": "*",
17+
"onlyDependOnLibsWithTags": ["*"]
18+
}
19+
]
20+
}
21+
]
22+
}
23+
},
24+
{
25+
"files": ["*.ts", "*.tsx"],
26+
"extends": ["plugin:@nrwl/nx/typescript"],
27+
"rules": {}
28+
},
29+
{
30+
"files": ["*.js", "*.jsx"],
31+
"extends": ["plugin:@nrwl/nx/javascript"],
32+
"rules": {}
33+
},
34+
{
35+
"files": ["*.spec.ts", "*.spec.tsx", "*.spec.js", "*.spec.jsx"],
36+
"env": {
37+
"jest": true
38+
},
39+
"rules": {}
40+
}
41+
]
42+
}

.vscode/extensions.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"recommendations": [
3-
43
"nrwl.angular-console",
5-
"esbenp.prettier-vscode"
4+
"esbenp.prettier-vscode",
5+
"firsttris.vscode-jest-runner",
6+
"dbaeumer.vscode-eslint"
67
]
78
}

README.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Rock, Paper, Scissors challenge
2+
3+
## Introduction
4+
5+
The repository acts as a springboard to get you started with creating the classic game: [Rock, Paper, Scissors][rps].
6+
7+
## The Challenge
8+
9+
You work in a game company, and you're hacking with some people on recreating the school playground classic "[Rock, Paper, Scissors][rps]" on the Web.
10+
11+
A skeleton of a UI has been created, but it doesn't work - it always returns `draw` for the outcome.
12+
13+
### Requirements
14+
15+
1. **Please commit early, commit often** - it's helpful to see the 'steps' taken to complete the challenge.
16+
1. **Limit time spent to 1 hour _maximum_** - Even if the code is incomplete.
17+
1. **Implement the game, as you see fit** - The UI should report `player-1-wins`, `player-2-wins`, `draw` 'Outcome' as appropriate, based on the input given (and the rules of "[Rock, Paper, Scissors][rps]").
18+
19+
The code will then be used as a conversation starter at your interview.
20+
21+
⚠ Ideally, please keep _your_ repository private.
22+
23+
---
24+
25+
## Getting Started
26+
27+
This project was scaffolded using [nx](https://nx.dev/) and is based on React, TypeScript and MUI.
28+
29+
Unit tests can be added using Jest and React Testing Library, integration tests via Cypress.
30+
31+
Using latest Node.js LTS `v18.x` (e.g. via [nvm](https://github.com/nvm-sh/nvm))
32+
33+
Install dependencies:
34+
35+
```shell
36+
npm i
37+
```
38+
39+
Spin up `api` (an Express.js app) and `ui` (a React.js app):
40+
41+
```shell
42+
npx nx serve api
43+
npx nx serve ui
44+
```
45+
46+
Open `ui` in browser http://localhost:4200/
47+
48+
Change code and see changes in browser.
49+
50+
Run unit tests:
51+
52+
```shell
53+
npx nx test api --watch
54+
npx nx test ui --watch
55+
```
56+
57+
Run Cypress tests:
58+
59+
```shell
60+
npx nx e2e ui-e2e
61+
```
62+
63+
[rps]:https://en.wikipedia.org/wiki/Rock_paper_scissors

babel.config.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"babelrcRoots": ["*"]
3+
}

jest.config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { getJestProjects } from '@nrwl/jest';
2+
3+
export default {
4+
projects: getJestProjects(),
5+
};

jest.preset.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const nxPreset = require('@nrwl/jest/preset').default;
2+
3+
module.exports = { ...nxPreset };

nx.json

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,49 @@
1313
"build": {
1414
"dependsOn": ["^build"],
1515
"inputs": ["production", "^production"]
16+
},
17+
"test": {
18+
"inputs": ["default", "^production", "{workspaceRoot}/jest.preset.js"]
19+
},
20+
"e2e": {
21+
"inputs": ["default", "^production"]
22+
},
23+
"lint": {
24+
"inputs": ["default", "{workspaceRoot}/.eslintrc.json"]
1625
}
1726
},
1827
"namedInputs": {
1928
"default": ["{projectRoot}/**/*", "sharedGlobals"],
20-
"production": ["default"],
21-
"sharedGlobals": []
29+
"production": [
30+
"default",
31+
"!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",
32+
"!{projectRoot}/tsconfig.spec.json",
33+
"!{projectRoot}/jest.config.[jt]s",
34+
"!{projectRoot}/.eslintrc.json"
35+
],
36+
"sharedGlobals": ["{workspaceRoot}/babel.config.json"]
2237
},
2338
"workspaceLayout": {
2439
"appsDir": "packages",
2540
"libsDir": "packages"
26-
}
41+
},
42+
"generators": {
43+
"@nrwl/react": {
44+
"application": {
45+
"style": "@emotion/styled",
46+
"unitTestRunner": "jest",
47+
"linter": "eslint",
48+
"babel": true
49+
},
50+
"component": {
51+
"style": "@emotion/styled"
52+
},
53+
"library": {
54+
"style": "@emotion/styled",
55+
"unitTestRunner": "jest",
56+
"linter": "eslint"
57+
}
58+
}
59+
},
60+
"defaultProject": "ui"
2761
}

0 commit comments

Comments
 (0)