2017-12-28 12:18:33 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								# Testing
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								We aim to keep the code coverage of Electron high. We ask that all pull
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								request not only pass all existing tests, but ideally also add new tests
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								to cover changed code and new scenarios. Ensuring that we capture as
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								many code paths and use cases of Electron as possible ensures that we
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								all ship apps with fewer bugs.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
										 
							
							
								This repository comes with linting rules for both JavaScript and C++ – 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								as well as unit and integration tests. To learn more about Electron's
							 
						 
					
						
							
								
									
										
										
										
											2018-03-14 00:07:36 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								coding style, please see the [coding-style ](coding-style.md ) document.
							 
						 
					
						
							
								
									
										
										
										
											2017-12-28 12:18:33 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								## Linting
  
						 
					
						
							
								
									
										
										
										
											2020-01-23 17:51:09 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-12-28 12:18:33 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								To ensure that your JavaScript is in compliance with the Electron coding
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								style, run `npm run lint-js` , which will run `standard`  against both
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								Electron itself as well as the unit tests. If you are using an editor
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								with a plugin/addon system, you might want to use one of the many
							 
						 
					
						
							
								
									
										
										
										
											2018-01-22 16:49:30 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								[StandardJS addons][standard-addons] to be informed of coding style
							 
						 
					
						
							
								
									
										
										
										
											2017-12-28 12:18:33 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								violations before you ever commit them.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								To run `standard`  with parameters, run `npm run lint-js --`  followed by
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								arguments you want passed to `standard` .
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								To ensure that your C++ is in compliance with the Electron coding style,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								run `npm run lint-cpp` , which runs a `cpplint`  script. We recommend that
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								you use `clang-format`  and prepared [a short tutorial ](clang-format.md ).
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								There is not a lot of Python in this repository, but it too is governed
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								by coding style rules. `npm run lint-py`  will check all Python, using
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								`pylint`  to do so. 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								## Unit Tests
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								To run all unit tests, run `npm run test` . The unit tests are an Electron
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								app (surprise!) that can be found in the `spec`  folder. Note that it has
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								its own `package.json`  and that its dependencies are therefore not defined
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								in the top-level `package.json` .
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-03-22 10:19:53 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								To run only specific tests matching a pattern, run `npm run test --
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								-g=PATTERN`, replacing the ` PATTERN` with a regex that matches the tests
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								you would like to run. As an example: If you want to run only IPC tests, you
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								would run `npm run test -- -g ipc` .
							 
						 
					
						
							
								
									
										
										
										
											2017-12-28 12:18:33 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								[standard-addons]: https://standardjs.com/#are -there-text-editor-plugins
							 
						 
					
						
							
								
									
										
										
										
											2019-07-18 18:51:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								### Testing on Windows 10 devices
  
						 
					
						
							
								
									
										
										
										
											2020-01-23 17:51:09 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#### Extra steps to run the unit test:
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								1.  Visual Studio 2019 must be installed. 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								2.  Node headers have to be compiled for your configuration. 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								   ```powershell
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								   ninja -C out\Testing third_party\electron_node:headers
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								   ```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								3.  The electron.lib has to be copied as node.lib. 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								   ```powershell
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								   cd out\Testing
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								   mkdir gen\node_headers\Release
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								   copy electron.lib gen\node_headers\Release\node.lib
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								   ```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								#### Missing fonts
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-07-18 18:51:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								[Some Windows 10 devices ](https://docs.microsoft.com/en-us/typography/fonts/windows_10_font_list ) do not ship with the Meiryo font installed, which may cause a font fallback test to fail. To install Meiryo:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								1.  Push the Windows key and search for _Manage optional features_ . 
						 
					
						
							
								
									
										
										
										
											2020-01-23 17:51:09 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								2.  Click _Add a feature_ . 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								3.  Select _Japanese Supplemental Fonts_  and click _Install_ . 
						 
					
						
							
								
									
										
										
										
											2019-08-08 21:59:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-01-23 17:51:09 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								#### Pixel measurements
  
						 
					
						
							
								
									
										
										
										
											2019-08-08 21:59:44 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								Some tests which rely on precise pixel measurements may not work correctly on
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								devices with Hi-DPI screen settings due to floating point precision errors.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								To run these tests correctly, make sure the device is set to 100% scaling.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								To configure display scaling:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
								
									
								 
							
							
								1.  Push the Windows key and search for _Display settings_ . 
						 
					
						
							
								
									
										
										
										
											2020-01-23 17:51:09 -08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
								
									
								 
							
							
								2.  Under _Scale and layout_ , make sure that the device is set to 100%.