Skip to content

Commit bd643a0

Browse files
committed
initial
0 parents  commit bd643a0

16 files changed

+26313
-0
lines changed

.gitignore

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
lerna-debug.log*
8+
.pnpm-debug.log*
9+
10+
# Diagnostic reports (https://nodejs.org/api/report.html)
11+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
12+
13+
# Runtime data
14+
pids
15+
*.pid
16+
*.seed
17+
*.pid.lock
18+
19+
# Directory for instrumented libs generated by jscoverage/JSCover
20+
lib-cov
21+
22+
# Coverage directory used by tools like istanbul
23+
coverage
24+
*.lcov
25+
26+
# nyc test coverage
27+
.nyc_output
28+
29+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
30+
.grunt
31+
32+
# Bower dependency directory (https://bower.io/)
33+
bower_components
34+
35+
# node-waf configuration
36+
.lock-wscript
37+
38+
# Compiled binary addons (https://nodejs.org/api/addons.html)
39+
build/Release
40+
41+
# Dependency directories
42+
node_modules/
43+
jspm_packages/
44+
45+
# Snowpack dependency directory (https://snowpack.dev/)
46+
web_modules/
47+
48+
# TypeScript cache
49+
*.tsbuildinfo
50+
51+
# Optional npm cache directory
52+
.npm
53+
54+
# Optional eslint cache
55+
.eslintcache
56+
57+
# Optional stylelint cache
58+
.stylelintcache
59+
60+
# Microbundle cache
61+
.rpt2_cache/
62+
.rts2_cache_cjs/
63+
.rts2_cache_es/
64+
.rts2_cache_umd/
65+
66+
# Optional REPL history
67+
.node_repl_history
68+
69+
# Output of 'npm pack'
70+
*.tgz
71+
72+
# Yarn Integrity file
73+
.yarn-integrity
74+
75+
# dotenv environment variable files
76+
.env
77+
.env.development.local
78+
.env.test.local
79+
.env.production.local
80+
.env.local
81+
82+
# parcel-bundler cache (https://parceljs.org/)
83+
.cache
84+
.parcel-cache
85+
86+
# Next.js build output
87+
.next
88+
out
89+
90+
# Nuxt.js build / generate output
91+
.nuxt
92+
dist
93+
94+
# Gatsby files
95+
.cache/
96+
# Comment in the public line in if your project uses Gatsby and not Next.js
97+
# https://nextjs.org/blog/next-9-1#public-directory-support
98+
# public
99+
100+
# vuepress build output
101+
.vuepress/dist
102+
103+
# vuepress v2.x temp and cache directory
104+
.temp
105+
.cache
106+
107+
# Docusaurus cache and generated files
108+
.docusaurus
109+
110+
# Serverless directories
111+
.serverless/
112+
113+
# FuseBox cache
114+
.fusebox/
115+
116+
# DynamoDB Local files
117+
.dynamodb/
118+
119+
# TernJS port file
120+
.tern-port
121+
122+
# Stores VSCode versions used for testing VSCode extensions
123+
.vscode-test
124+
125+
# yarn v2
126+
.yarn/cache
127+
.yarn/unplugged
128+
.yarn/build-state.yml
129+
.yarn/install-state.gz
130+
.pnp.*
131+
132+
.DS_Store

README.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Integration Testing React Module Project : Contact Form - Testing
2+
3+
This module explored the basics of the react-testing library and ideas behind the integration testing methodology. In this project you will practice how to build tests that follow the arrange-act-assert model, different methods of querying for DOM elements in a test, the use of different expect types and using async/await to test for changes in state.
4+
5+
## Testing Web Applications
6+
7+
## Objectives
8+
9+
- explain what automated testing is and its importance
10+
- use react-testing-library for testing react components
11+
- use react-testing-library to test user interactions with userEvent
12+
- use async / await and waitFor to test changes in a components state.
13+
14+
## Introduction
15+
16+
In this challenge, you will be writing tests for a contact form that has been built with React.
17+
18+
As a developer, you will be writing tests for every component. As we've learned, tests are a very important part of programming. The tests you will write will help you feel confident in the code you push to production!
19+
20+
![Contact Example](project-goals.gif)
21+
22+
***Make sure to complete your tasks one at a time and complete test each task before proceding forward.***
23+
24+
## Instructions
25+
26+
### Task 1: Project Set Up
27+
28+
- [ ] Create a forked copy of this project.
29+
- [ ] Clone your OWN version of the repository in your terminal
30+
- [ ] Download project dependencies by running `npm install`
31+
- [ ] Start up the app using `npm start`
32+
- [ ] In a new terminal window, run `npm test`
33+
- [ ] With each saved change in your editor, the test runner will re-run all the tests
34+
- [ ] **IMPORTANT** If a test fails, use the test runner's error messages to find out why it is failing
35+
36+
### Task 2: Project Requirements
37+
38+
> *All of the work you will do today will be contained inside the ContactForm.test.js file. You will be tasked to write the code for at least 9 different tests on various parts of the ContactForm component. Please read the instructions for each test carefully.*
39+
40+
#### Test Brainstorming
41+
42+
* [ ] Run and play around with the form interface.
43+
* [ ] Write out a list of possible testcases for this application within Understanding-questions.md.
44+
45+
#### Complete a case that tests if
46+
47+
* [ ] the component renders the contact form component without errors.
48+
* [ ] the header h1 element exists. Include three asserts, if the header is in the document, if the heads is truthy, if the header has the correct test content.
49+
* [ ] the component renders ONE error message if the user enters less than 4 characters into the firstname field. Make sure to use async / await and the correct screen method to account for state change.
50+
* [ ] the component renders THREE error messages if the user submits without filling in any values.
51+
* [ ] the component renders ONE error message if the user submits without filling in the email field.
52+
* [ ] the component renders the text *"email must be a valid email address"* if an invalid email address is typed into the email field.
53+
* [ ] the component renders the text *"lastName is a required field"* the form is submitted without a last name.
54+
* [ ] the component renders the firstname, lastname and email text when submitted with valued fields and does **not** render a message value when one is not entered into the message field.
55+
* [ ] renders all fields when the user submits with valid text filled in for all fields.
56+
57+
## Stretch goals
58+
59+
- Look at your test cases in Understanding-questions and see if there are any that you have not completed.
60+
- From the this list or from your own mind, add in at least one more new testcase.
61+
- There is alot of state management within our component in this project! See if you can separate the form and error validation code into their own hooks.

babel.config.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
const PLUGIN_TRANSFORM_RUNTIME = '@babel/plugin-transform-runtime'
2+
const PLUGIN_STYLED_COMPONENTS = 'babel-plugin-styled-components'
3+
4+
const PRESET_REACT = '@babel/preset-react'
5+
const PRESET_ENV = '@babel/preset-env'
6+
7+
module.exports = {
8+
env: {
9+
testing: {
10+
plugins: [
11+
[PLUGIN_TRANSFORM_RUNTIME],
12+
],
13+
presets: [
14+
[PRESET_REACT],
15+
[PRESET_ENV, { modules: 'commonjs', debug: false }]
16+
]
17+
},
18+
development: {
19+
plugins: [
20+
[PLUGIN_STYLED_COMPONENTS],
21+
],
22+
presets: [
23+
[PRESET_REACT],
24+
[PRESET_ENV, { targets: { chrome: '96' } }]
25+
]
26+
},
27+
production: {
28+
plugins: [
29+
[PLUGIN_STYLED_COMPONENTS],
30+
],
31+
presets: [
32+
[PRESET_REACT],
33+
[PRESET_ENV, { targets: { chrome: '96' } }]
34+
]
35+
},
36+
}
37+
}

frontend/.eslintrc.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es2021": true,
5+
"node": true,
6+
"jest": true
7+
},
8+
"extends": [
9+
"eslint:recommended",
10+
"plugin:react/recommended"
11+
],
12+
"parserOptions": {
13+
"ecmaFeatures": {
14+
"jsx": true
15+
},
16+
"ecmaVersion": "latest",
17+
"sourceType": "module"
18+
},
19+
"plugins": [
20+
"react"
21+
],
22+
"rules": {
23+
"react/prop-types": 0,
24+
"semi": [
25+
"error",
26+
"always"
27+
]
28+
}
29+
}

frontend/App.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import React from 'react';
2+
import ContactForm from './components/ContactForm';
3+
4+
const App = () => {
5+
return (
6+
<div>
7+
<nav className="navbar navbar-dark bg-dark">
8+
<a className="navbar-brand" href="#">Integration Testing Challenge</a>
9+
</nav>
10+
<div className="App">
11+
<ContactForm />
12+
</div>
13+
</div>
14+
)
15+
}
16+
17+
export default App;

0 commit comments

Comments
 (0)