-
Notifications
You must be signed in to change notification settings - Fork 309
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
feat: restructure project with src/ and build/ #307
Conversation
ad42ae6
to
7064a42
Compare
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
If you choose to overide `globals` in order to point at a specific tsconfig, you will need to add `"astTransformers": ["jest-preset-angular/InlineHtmlStripStylesTransformer"]` to the `globals.ts-jest` section too, otherwise you will get parse errors on any html templates. | ||
If you choose to overide `globals` in order to point at a specific tsconfig, you will need to add the `astTransformers` to the `globals.ts-jest` section too, otherwise you will get parse errors on any html templates. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about linking to the specific lines in the source file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Custom tsconfig with the full example part is just right above this line, I think that is easy enough to copy. If we link the full preset, they might copy wrong parts, like "astTransformer": ["./build/Transformer"]
, so I actually prefer this style.
Plus the configuration is linked on the very top of the README.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__tests__/CoreJS-es6-reflect.test.ts
Outdated
@@ -24,21 +24,21 @@ describe('importing ES6 reflect', () => { | |||
jest.mock('core-js/es6/reflect', () => { throw coreJs2Error }, { virtual: true }); | |||
jest.mock('core-js/es/reflect', () => { throw coreJs3Error }, { virtual: true }); | |||
|
|||
expect(() => require('../setupJest')).toThrow('core-js es6-reflect not found!'); | |||
expect(() => require('../src/setupJest')).toThrow('core-js es6-reflect not found!'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's move this test into src/
instead :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just put it inside src/
: src/CoreJS-es6-reflect.test.ts
, better have a look at the folder structure in this branch.
Is this ok? The __snapshot__
folder also lives inside src/
now. Or do you think we should separate them somewhat from the source files?
IMO with the relative small amount of source files it is ok to keep them in one folder for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm why don't we leave test files in src/__tests__
? I think it's better and it's a pattern used by each jest package folder too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right! I argued with being inspired by the facebook/jest setup!
Would you put the tsconfig.spec.json
for the preset tests inside there too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that makes sense 👍
👍 |
7064a42
to
aa23c9d
Compare
To keep source files in a single place, most js files are now located in the src folder as well. The TypeScript compiler transpiles the ts files and copies the js files to the build folder.
aa23c9d
to
d60bc4f
Compare
@@ -11,5 +11,5 @@ | |||
"types": ["node"] | |||
}, | |||
"include": ["src"], | |||
"exclude": [] | |||
"exclude": ["**/__tests__"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to exclude tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, otherwise tsc
will also compile src/__tests__/**
to build/
Problem
More and more js files such as serializers were located in the root of the project separated from ts src files, while these ts files also got transpiled to the root folder. This creates a non-transparent file mix with compiled and source files in the same place.
PR
To keep source files in a single place, most js files are now located in the src folder as well. A build folder will be created on
npm run build
,yarn build
ornpm run prepare
, as configured intsconfig.json
.The TypeScript compiler transpiles the ts files and conventiently copies the js files to the build folder. This means the js files are not changed by the tsc.
I kept the
index.js
andjest-preset.js
in the root folder, as otherwise the preset would not be referenceable as justjest-preset-angular
from the jest config.All other js files, such as transformers and serializers have to be referenced as
jest-preset-angular/build/...
now. This makes this change a breaking change, as many users will have to adjust their configuration.On the other hand this makes it much more easy for us maintainers and new contributers to work with the source files, as the project setup is more intuitive.
The naming of
build
was inspired byfacebook/jest
.