Open deraw opened 5 years ago
Hey 👋 ,
I'm glad that you like the project.
Could you please add the following configuration to package.json
and check?
"majestic": {
"jestScriptPath": ".\\node_modules\\@vue\\cli-service\\bin\\vue-cli-service.js test:unit"
}
Thanks for your quick reply!
(I've had to replace \\
with /
)
It's using vu-cli-service now, but it seems it's without the config for jest (defined in the package.json
)
If I run ./node_modules/@vue/cli-service/bin/vue-cli-service.js test:unit
in the terminal the tests passes
But in the GUI it says Jest encountered an unexpected token
(also I'm using TypeScript)
I created a new project via the Vue CLI with Jest (Config in package.json) + typescript and I can run the project. So I'm not sure why your one is not working. If you could share a small repo with the issue, I can take a look into it.
You're right I've tried with another similar project and it worked like a charm! I'll try to see what's causing the error in the first project
I haven't touched anything, but now it works! Thank you :smile:
Hey again 👋 ,
From Majestic 1.3 (Which I released just now) onwards the config needs to be as follows.
"majestic": {
"jestScriptPath": ".\\node_modules\\@vue\\cli-service\\bin\\vue-cli-service.js",
"args": [
"test:unit"
]
}
Cheers!
Hi!
Thank you that's very kind of you!
I also love the coverage integration! :ok_hand:
Forgive me if this is a stupid question, but does the jestScriptPath have to be a JS file to be executed with node, or can it be configured to execute a binary? To run things up with my setup I have to run ng test or yarn test, which will then compile the relevant jest config and run up jest, but I'm not sure how to configure majestic to work with that.
It could be any binary but the binary that you provide should forward the args correctly to Jest at the end otherwise things won't work.
Would you be able to share whats in your yarn test
script has so I could see how we can make it work?
There are no stupid questions :)
Thanks @Raathigesh, any thoughts you have would be appreciated :)
My yarn test
script actually doesn't do much, it just calls ng test
.
I'm using @angular-builders/jest. My understanding is that it:
ng test ...jest-args-can-go-here
at the command line)If I run this command in the terminal (from the project root folder), I see the test results all ok in the terminal:
ng test myproject
I tried adding the following to my package.json and then running majestic:
"majestic": { "jestScriptPath": "ng test myproject" }
but when it starts up I see this error in the (web browser) console:
ui.bundle.js:42 TypeError: Cannot read property 'projectRoot' of undefined
hey 👋 ,
I created a sample project and I was able to start majestic with the following config.
"majestic": {
"jestScriptPath": ".\\node_modules\\@angular\\cli\\bin\\ng",
"args": [
"test"
]
}
You can add more arguments to the args
array like the project name.
Let me know if you run into issues.
Hey @Raathigesh, thanks for the amazing work!
I'm trying to make it work with vue-cli as well but it looks like it's just ignoring my jest.config.js
file.
I use the following config:
{
"majestic": {
"jestScriptPath": "./node_modules/@vue/cli-service/bin/vue-cli-service.js",
"env": {
"TEST_MODE": "unit"
},
"args": [
"test:unit",
"--config=./jest.config.js",
"--testPathPattern=/unit/",
"--runInBand"
]
}
}
And when I run majestic --debug
I'm getting:
⚡ Majestic v1.4.1 is running at http://localhost:4000
ℹ Majestic configuration from Package.json: { Config Resolver 16:22:54
jestScriptPath: './node_modules/@vue/cli-service/bin/vue-cli-service.js',
env: {
TEST_MODE: 'unit'
},
args: [
'test:unit',
'--config=./jest.config.js',
'--testPathPattern=/unit/',
'--runInBand'
]
}
ℹ Resolved Majestic config : { Config Resolver 16:22:54
jestScriptPath: '"/home/pirhoo/Repositories/datashare-client/node_modules/@vue/cli-service/bin/vue-cli-service.js"',
args: [
'test:unit',
'--config=./jest.config.js',
'--testPathPattern=/unit/',
'--runInBand'
],
env: {
TEST_MODE: 'unit'
}
}
ℹ Error occured while obtaining Jest cofiguration for coverage report
Any clue?
Hey @pirhoo,
It seems like there is something going on when obtaining coverage report path. Unfortunately, the error is not printed to the output but it should have been. I'll do a release with enhanced error logging so we could see what's going on and also fixed a few things around this area so thing might work as well.
I'll ping here after releasing the next version in a couple of days so you could check again.
Copy that, thanks @Raathigesh !
Hi again @pirhoo 👋 ,
Released 1.5.0. Could you please try again.
Thanks for the doing this so quickly @Raathigesh!
The error is a little bit more explicit now:
ℹ Error occured while obtaining Jest cofiguration for coverage report SyntaxError: Unexpected token d in JSON at position 1
The Jest config is here and works well when executed with jest (thought vue-cli-service). The package.json
is also valid.
I checked out the repo and it looks like when I provide the --app
flag, I see the error but without the --app
flag, it works. Are you seeing the same behavior?
You're right, Majestic works well without the --app
flag :dizzy_face:
That doesn't add up. I'll have a look at it.
(in the meantime I'm using the --noOpen
flag - it's great)
hey y'all, what if you have more than one test script, for example
{
"scripts": {
"test": "jest -c jest.config.unit.js",
"itest": "jest -c jest.config.integration.js",
}
}
Feature Request
Hi! I've discovered this project and I love it, thank you for making it!
I was wondering if it's possible to specify a command to execute, or to make it work with vue-cli I'm using the command
vue-cli-service test:unit
, and my tests are passing, but with the GUI I suppose it runs Jest directly so it fails with:Thanks!