Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7f2833b

Browse files
committed
Add unit tests for homework reviews
1 parent a7e2459 commit 7f2833b

15 files changed

+5806
-2
lines changed

.eslintrc.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@
22
"extends": ["airbnb", "prettier"],
33
"plugins": ["prettier"],
44
"env": {
5-
"browser": true
5+
"browser": true,
6+
"jest": true
7+
},
8+
"globals": {
9+
"page": true,
10+
"browser": true,
11+
"context": true,
12+
"jestPuppeteer": true
613
},
714
"rules": {
815
"prettier/prettier": ["error"],

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,4 @@ typings/
5959

6060
.netlify
6161
dist/
62+
iPhoneX.png

Week1/MAKEME.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ It should include the following components:
164164
3. When the user changes the selection, the information in the web page should be refreshed for the newly selected repository.
165165
4. You should be able to click on the repository name of the selected repository to open a new browser tab with the GitHub page for that repository.
166166
5. You should be able to click on a contributor to open a new browser tab with the GitHub page for that contributor.
167-
6. You should render network errors to the DOM (see Figure 2 below for an example). Do not use `console.log` as regular users will not see the console output.
167+
6. You should render network errors to the DOM (see Figure 2 below for an example). Do not use `console.log` as regular users will not see the console output. Use the predefined `alert-error` class from `style.css` to style your error.
168168
7. Your UI should be responsive. Try it with Chrome Developer Tools in the browser, using a mobile phone format and a tablet format, portrait and landscape. If necessary, you can also do this work in week 2.
169169

170170
![Error rendering](./assets/hyf-github-error.png)

test/jest-puppeteer.config.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = {
2+
server: {
3+
command: 'serve ../homework',
4+
port: 5000,
5+
},
6+
launch: {
7+
headless: true,
8+
},
9+
// could use for example: 1920 x 1080
10+
defaultViewPort: {
11+
width: 800,
12+
height: 600,
13+
},
14+
};

test/jest.config.js

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
// For a detailed explanation regarding each configuration property, visit:
2+
// https://jestjs.io/docs/en/configuration.html
3+
4+
module.exports = {
5+
preset: 'jest-puppeteer',
6+
// All imported modules in your tests should be mocked automatically
7+
// automock: false,
8+
9+
// Stop running tests after `n` failures
10+
// bail: 0,
11+
12+
// Respect "browser" field in package.json when resolving modules
13+
// browser: false,
14+
15+
// The directory where Jest should store its cached dependency information
16+
// cacheDirectory: "/private/var/folders/z9/94jqvx5d6pj83s6_7_n0wjlr0000gn/T/jest_dx",
17+
18+
// Automatically clear mock calls and instances between every test
19+
// clearMocks: false,
20+
21+
// Indicates whether the coverage information should be collected while executing the test
22+
// collectCoverage: false,
23+
24+
// An array of glob patterns indicating a set of files for which coverage information should be collected
25+
// collectCoverageFrom: null,
26+
27+
// The directory where Jest should output its coverage files
28+
// coverageDirectory: null,
29+
30+
// An array of regexp pattern strings used to skip coverage collection
31+
// coveragePathIgnorePatterns: [
32+
// "/node_modules/"
33+
// ],
34+
35+
// A list of reporter names that Jest uses when writing coverage reports
36+
// coverageReporters: [
37+
// "json",
38+
// "text",
39+
// "lcov",
40+
// "clover"
41+
// ],
42+
43+
// An object that configures minimum threshold enforcement for coverage results
44+
// coverageThreshold: null,
45+
46+
// A path to a custom dependency extractor
47+
// dependencyExtractor: null,
48+
49+
// Make calling deprecated APIs throw helpful error messages
50+
// errorOnDeprecated: false,
51+
52+
// Force coverage collection from ignored files using an array of glob patterns
53+
// forceCoverageMatch: [],
54+
55+
// A path to a module which exports an async function that is triggered once before all test suites
56+
// globalSetup: null,
57+
58+
// A path to a module which exports an async function that is triggered once after all test suites
59+
// globalTeardown: null,
60+
61+
// A set of global variables that need to be available in all test environments
62+
// globals: {},
63+
64+
// An array of directory names to be searched recursively up from the requiring module's location
65+
// moduleDirectories: [
66+
// "node_modules"
67+
// ],
68+
69+
// An array of file extensions your modules use
70+
// moduleFileExtensions: [
71+
// "js",
72+
// "json",
73+
// "jsx",
74+
// "ts",
75+
// "tsx",
76+
// "node"
77+
// ],
78+
79+
// A map from regular expressions to module names that allow to stub out resources with a single module
80+
// moduleNameMapper: {},
81+
82+
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
83+
// modulePathIgnorePatterns: [],
84+
85+
// Activates notifications for test results
86+
// notify: false,
87+
88+
// An enum that specifies notification mode. Requires { notify: true }
89+
// notifyMode: "failure-change",
90+
91+
// A preset that is used as a base for Jest's configuration
92+
// preset: null,
93+
94+
// Run tests from one or more projects
95+
// projects: null,
96+
97+
// Use this configuration option to add custom reporters to Jest
98+
// reporters: undefined,
99+
100+
// Automatically reset mock state between every test
101+
// resetMocks: false,
102+
103+
// Reset the module registry before running each individual test
104+
// resetModules: false,
105+
106+
// A path to a custom resolver
107+
// resolver: null,
108+
109+
// Automatically restore mock state between every test
110+
// restoreMocks: false,
111+
112+
// The root directory that Jest should scan for tests and modules within
113+
// rootDir: null,
114+
115+
// A list of paths to directories that Jest should use to search for files in
116+
// roots: [
117+
// "<rootDir>"
118+
// ],
119+
120+
// Allows you to use a custom runner instead of Jest's default test runner
121+
// runner: "jest-runner",
122+
123+
// The paths to modules that run some code to configure or set up the testing environment before each test
124+
// setupFiles: [],
125+
126+
// A list of paths to modules that run some code to configure or set up the testing framework before each test
127+
// setupFilesAfterEnv: [],
128+
129+
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
130+
// snapshotSerializers: [],
131+
132+
// The test environment that will be used for testing
133+
// testEnvironment: "jest-environment-jsdom",
134+
135+
// Options that will be passed to the testEnvironment
136+
// testEnvironmentOptions: {},
137+
138+
// Adds a location field to test results
139+
// testLocationInResults: false,
140+
141+
// The glob patterns Jest uses to detect test files
142+
// testMatch: [
143+
// "**/__tests__/**/*.[jt]s?(x)",
144+
// "**/?(*.)+(spec|test).[tj]s?(x)"
145+
// ],
146+
147+
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
148+
// testPathIgnorePatterns: [
149+
// "/node_modules/"
150+
// ],
151+
152+
// The regexp pattern or array of patterns that Jest uses to detect test files
153+
// testRegex: [],
154+
155+
// This option allows the use of a custom results processor
156+
// testResultsProcessor: null,
157+
158+
// This option allows use of a custom test runner
159+
// testRunner: "jasmine2",
160+
161+
// This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
162+
// testURL: "http://localhost",
163+
164+
// Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
165+
// timers: "real",
166+
167+
// A map from regular expressions to paths to transformers
168+
// transform: null,
169+
170+
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
171+
// transformIgnorePatterns: [
172+
// "/node_modules/"
173+
// ],
174+
175+
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
176+
// unmockedModulePathPatterns: undefined,
177+
178+
// Indicates whether each individual test should be reported during the run
179+
// verbose: null,
180+
181+
// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
182+
// watchPathIgnorePatterns: [],
183+
184+
// Whether to use watchman for file crawling
185+
// watchman: true,
186+
};

0 commit comments

Comments
 (0)