Skip to content
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

Support for libraries? #22

Closed
fireflysemantics opened this issue Dec 5, 2019 · 4 comments · Fixed by #41
Closed

Support for libraries? #22

fireflysemantics opened this issue Dec 5, 2019 · 4 comments · Fixed by #41

Comments

@fireflysemantics
Copy link

Is your feature request related to a problem? Please describe.
Running the schematic on an Angular application project seems to be working fine, but when I run it on a library project it fails.

Here are some sample errors that I'm seeing:

    SyntaxError: /home/ole/Github/slice/angular-package-format-workspace/projects/slice/src/lib/OStore.spec.ts: Unexpected token, expected ";" (8:12)

       6 | 
       7 | describe("Creating a key value store", () => {
    >  8 |   let ostore: OStore = new OStore();
         |             ^
       9 | 
      10 |   it("should create an empty key value store", () => {
      11 |     expect(ostore.isEmpty()).toBeTruthy();

      at Parser.raise (../../node_modules/@babel/parser/lib/index.js:6975:17)
      at Parser.unexpected (../../node_modules/@babel/parser/lib/index.js:8368:16)
      at Parser.semicolon (../../node_modules/@babel/parser/lib/index.js:8350:40)
      at Parser.parseVarStatement (../../node_modules/@babel/parser/lib/index.js:11127:10)
      at Parser.parseStatementContent (../../node_modules/@babel/parser/lib/index.js:10723:21)
      at Parser.parseStatement (../../node_modules/@babel/parser/lib/index.js:10656:17)
      at Parser.parseBlockOrModuleBlockBody (../../node_modules/@babel/parser/lib/index.js:11232:25)
      at Parser.parseBlockBody (../../node_modules/@babel/parser/lib/index.js:11219:10)
      at Parser.parseBlock (../../node_modules/@babel/parser/lib/index.js:11203:10)
      at Parser.parseFunctionBody (../../node_modules/@babel/parser/lib/index.js:10222:24)


       6 | 
       7 | describe("Creating a key value store", () => {
    >  8 |   let ostore: OStore = new OStore();
         |             ^
       9 | 
      10 |   it("should create an empty key value store", () => {
      11 |     expect(ostore.isEmpty()).toBeTruthy();

It looks like jest does not understand typescript in this case. I'm assuming that we just have to add the normal Jest / Typescript setup.

Describe the solution you'd like

Automatic addition of support for libraries when we run:


ng add @briebug/jest-schematic
@fireflysemantics
Copy link
Author

I just followed these instructions for adding testing Typescript with Jest:

https://basarat.gitbooks.io/typescript/docs/testing/jest.html

And now the project compiles fine. So I guess it's just a matter of having the schematic install the dependencies and adding the jest.config.js file.

@fireflysemantics
Copy link
Author

@schuchard
Copy link
Collaborator

Thanks for looking into this. Library support is something I'd like to add at some point. I'll keep this issue open as a reminder.

schuchard added a commit that referenced this issue Sep 2, 2020
Add support single application projects and workspaces with apps and libraries. 

## Jest runner

Replace the direct reliance on [`jest-preset-angular`](https://github.com/thymikee/jest-preset-angular) and package json scripts in favor of [`angular-builders/jest`](https://github.com/just-jeb/angular-builders/tree/master/packages/jest). This provides the ability to run tests with `ng test`

This should address #30 #28 #22 #11 
It better positions us to support #1 

## Jest types

Update each projects `tsconfig.spec.json` to configure the `jest` types while removing `jasmine`

This should address #24 #14

## Other
Non-user facing changes 

- refactor development scripts from `package.json` to TS file
- create 2 sandboxes (single app and workspace with app and lib)
- test both sandboxes during CI
- add MIT license
- add prettier
@schuchard
Copy link
Collaborator

Please see if ng add @briebug/[email protected] solves the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants