forked from wix/Detox
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extend the documentation around code generation
- Loading branch information
1 parent
6553486
commit ff265ae
Showing
2 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,33 @@ | ||
# Generation | ||
|
||
This part of the repository aims to automate the adaption of the underlying testing frameworks. | ||
For now, it only covers `EarlGrey`'s `GREYActions`. | ||
|
||
We chose to check the generated files into version control to have them available as documentation. | ||
|
||
To correlate changes to the generation with changes in the generated code, please make sure to run the build before every commit. | ||
|
||
## Development | ||
|
||
- `npm install` | ||
- `npm run build` builds every file specified in the `index.js` | ||
- `npm test` runs integration level tests | ||
- `npm test` | ||
|
||
## Testing | ||
|
||
- We test with integration level tests by having a fixture Objective-C file which we generate and import before the tests. | ||
- We only add unit tests for code that is used in production, e.g. helper functions. | ||
- We then test against this file to ensure that the code generation result works with the specified interface. | ||
- We decided to base our tests around snapshot tests with the goal to spot mistakes in the return values of the functions without over-specification. | ||
- If you add functionality that affects the API surface of detox, please also make sure to include [End to End tests for it](../detox/test/e2e). | ||
|
||
## Resources | ||
|
||
Parsing, ASTs, and code generation are hard topics but don't worry; we got your back. | ||
Here are some resources that might come in handy: | ||
|
||
- [astexplorer](https://astexplorer.net): Allows you to understand Abstract Syntax Trees by showing you code and the resulting AST side-by-side. | ||
- [Babel Handbook](https://github.com/thejameskyle/babel-handbook): | ||
- [babel-types](https://github.com/babel/babel/tree/master/packages/babel-types): A builder library for ASTs. | ||
- [babel-template](https://github.com/babel/babel/tree/master/packages/babel-template): A useful tool we do not use yet for generating bigger ASTs with less code by the usage of string interpolation. | ||
- [regex101](https://regex101.com): You might need to extract parts of a string; This tool helps you to quickly build the right Regular Expression for the job. |