Skip to content

rock paper scissors base #2

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

Open
wants to merge 15 commits into
base: main
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
42 changes: 42 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"root": true,
"ignorePatterns": ["**/*"],
"plugins": ["@nrwl/nx"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {
"@nrwl/nx/enforce-module-boundaries": [
"error",
{
"enforceBuildableLibDependency": true,
"allow": [],
"depConstraints": [
{
"sourceTag": "*",
"onlyDependOnLibsWithTags": ["*"]
}
]
}
]
}
},
{
"files": ["*.ts", "*.tsx"],
"extends": ["plugin:@nrwl/nx/typescript"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nrwl/nx/javascript"],
"rules": {}
},
{
"files": ["*.spec.ts", "*.spec.tsx", "*.spec.js", "*.spec.jsx"],
"env": {
"jest": true
},
"rules": {}
}
]
}
5 changes: 3 additions & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"recommendations": [

"nrwl.angular-console",
"esbenp.prettier-vscode"
"esbenp.prettier-vscode",
"firsttris.vscode-jest-runner",
"dbaeumer.vscode-eslint"
]
}
63 changes: 63 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Rock, Paper, Scissors challenge

## Introduction

The repository acts as a springboard to get you started with creating the classic game: [Rock, Paper, Scissors][rps].

## The Challenge

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.

A skeleton of a UI has been created, but it doesn't work - it always returns `draw` for the outcome.

### Requirements

1. **Please commit early, commit often** - it's helpful to see the 'steps' taken to complete the challenge.
1. **Limit time spent to 1 hour _maximum_** - Even if the code is incomplete.
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]").

The code will then be used as a conversation starter at your interview.

⚠ Ideally, please keep _your_ repository private.

---

## Getting Started

This project was scaffolded using [nx](https://nx.dev/) and is based on React, TypeScript and MUI.

Unit tests can be added using Jest and React Testing Library, integration tests via Cypress.

Using latest Node.js LTS `v18.x` (e.g. via [nvm](https://github.com/nvm-sh/nvm))

Install dependencies:

```shell
npm i
```

Spin up `api` (an Express.js app) and `ui` (a React.js app):

```shell
npx nx serve api
npx nx serve ui
```

Open `ui` in browser http://localhost:4200/

Change code and see changes in browser.

Run unit tests:

```shell
npx nx test api --watch
npx nx test ui --watch
```

Run Cypress tests:

```shell
npx nx e2e ui-e2e
```

[rps]:https://en.wikipedia.org/wiki/Rock_paper_scissors
3 changes: 3 additions & 0 deletions babel.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"babelrcRoots": ["*"]
}
5 changes: 5 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { getJestProjects } from '@nrwl/jest';

export default {
projects: getJestProjects(),
};
3 changes: 3 additions & 0 deletions jest.preset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const nxPreset = require('@nrwl/jest/preset').default;

module.exports = { ...nxPreset };
40 changes: 37 additions & 3 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,49 @@
"build": {
"dependsOn": ["^build"],
"inputs": ["production", "^production"]
},
"test": {
"inputs": ["default", "^production", "{workspaceRoot}/jest.preset.js"]
},
"e2e": {
"inputs": ["default", "^production"]
},
"lint": {
"inputs": ["default", "{workspaceRoot}/.eslintrc.json"]
}
},
"namedInputs": {
"default": ["{projectRoot}/**/*", "sharedGlobals"],
"production": ["default"],
"sharedGlobals": []
"production": [
"default",
"!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",
"!{projectRoot}/tsconfig.spec.json",
"!{projectRoot}/jest.config.[jt]s",
"!{projectRoot}/.eslintrc.json"
],
"sharedGlobals": ["{workspaceRoot}/babel.config.json"]
},
"workspaceLayout": {
"appsDir": "packages",
"libsDir": "packages"
}
},
"generators": {
"@nrwl/react": {
"application": {
"style": "@emotion/styled",
"unitTestRunner": "jest",
"linter": "eslint",
"babel": true
},
"component": {
"style": "@emotion/styled"
},
"library": {
"style": "@emotion/styled",
"unitTestRunner": "jest",
"linter": "eslint"
}
}
},
"defaultProject": "ui"
}
Loading