I have multiple NodeJs packages in structure like
//repoRoot/CompA
//repoRoot/CompB
//repoRoot/CompC
I know this might sound really weird, but, I have dockerfile with parameters and run it three times, like
FROM myImg
ARG SourceDir
WORKDIR /workspace
COPY SourceDir/. .
RUN yarn test (this calls `jest --config jestconfig.json --coverage`)
And I wanted combine the resulting coverage reports.
Copying the files are easy, but, source file paths inside the coverage reports is like
/workspace/src/file1.js
/workspace/src/file2.js
When I wanted them to be
/workspace/CompA/src/file1.js
/workspace/CompA/src/file2.js
How should I accomplish this?
Is there a jest configuration I can do this? Or do I really need to do some string replace for all the reports?
Thank you
NVM, instead of using jest config. I just use sed to replace the string instead.
Related
My file structure would look something like:
./client
.react
./server
.express
.express and .react are just shorthand for all of my files in these folders. So I have separate node_modules folders for each of these directories.
I wouldn't do it with npm itself. It might be handy to create a Makefile in the root, running your required build steps.
This article explains how to create a Makefile.
This same happen to me when I worked on the good solution is to make top level on these two workspaces. Just visit the given url workspaces you will get the idea how to manage that kind of flow and single top level package.json
You need to use npm run build to build the react app
I currently have my NodeJS source files in src and test suites in test, e.g.:
/src/bar/baz/foo.js
/test/bar/baz/foo.spec.js
This leads to awkward require statements like var foo = require('../../../src/bar/baz/foo'). And it's hard to see at a glance which source files are missing tests. I would like to instead keep my test suites in the same directory as the relevant source files:
/src/bar/baz/foo.js
/src/bar/baz/foo.spec.js
But now running mocha --recursive src causes errors as Mocha tries to run my source files as tests.
I've seen suggestions of using find or gulp to filter the file list but I find it surprising that this can't be done with plain Mocha. What's the recommended way of organising files this way?
Just pass the pattern of your test files to mocha, like:
mocha "src/**/*.spec.js"
This is going to run the .spec.js files in all subdirectories of src.
I have a Javascript project which uses Grunt for build process, QUnit for tests, Blanket for code coverage and a custom Grunt task to convert coverage results into LCOV files, sended to Coveralls. Everything running on TravisCI.
the project : https://github.com/mistic100/jQuery-QueryBuilder
my Grunt task : https://github.com/mistic100/grunt-qunit-blanket-lcov
So what should happen is that npm test runs QUnit+Blanket tests in a PhantomJS process and in the meanwhile, coverage results are saved in .coverage-results/all.lcov.
After a successfull build, grunt coveralls sends this file to Coveralls.
And my problem is here, the task does not find the file, although when I test on my computer it does.
see the last Travis log: https://travis-ci.org/mistic100/jQuery-QueryBuilder#L389
The only thing I can think about is that the file, for some reason, is deleted once npm test is finished. Is it possible ?
edit
so this has nothing to do with Travis but with my Grunt task where I use absolute paths thinking it's relative paths (I still don't know why it doesn't append on Windows though)
The only thing I can think about is that the file, for some reason, is deleted once npm test is finished. Is it possible ?
No, lifecycle-wise the build artefacts are still present, when running after_success commands.
The gruntfile.js configures force true and defines path - no issue here.
This should work.
I would suggest to throw in some commands to check the folders and files on Travis.
- sudo ls -alh /home/travis/build/mistic100/jQuery-QueryBuilder/*
- sudo ls -alh /home/travis/build/mistic100/jQuery-QueryBuilder/.coverage-results/*
Maybe you spot a permission issue during folder and file creation.
But that's my only guess.
I am trying to run a git bisect while using our automated tests to check the commit if it is the one causing the defect. The structure of our program is:
app
- cucumber_tests
- features/
- main_features/
- cucumber.yml
- src/
Obviously this is not the default/standard folder structure for running Cucumber tests as you would want the features folder to be at top-level of your app. This was not my choice and cannot be changed.
I can run the tests by cd into cucumber_test and then run. However, in order to run git bisect it must be done at same level as the .git folder.
My question is: is there a way to run the Cucumber tests from a parent directory of the features folder in Cucumber? Being able to read the cucumber.yml file would also be very beneficial.
Is there a way to tell Cucumber that you are not using the standard folder structure?
Edit: I have been able to get the tests started by using cucumber -r cucumber_tests/features cucumber_tests/features/main_features/first.feature. However, it is unable to find some of the step definitions part-way through the test.
It appears that cucumber is looking for files in app/features not app/cucumber_tests/features
You can still use the same folder structure. But you need to change the parameters in order to run your features. Otherwise this will not load step definitions. I hope you have step definitions inside the features folder. So now use this command to run the features: cucumber -r <absolute path of the features folder[C:\users\xyz\project\some_folder\features] absolute_path_feature_file[C:\users\xyz\project\some_folder\features\example.feature]
This way you cucumber will load your step definitions even if you have a different folder structure.
I'm using jasmine-node to test my Meteor application and I want to use the auto-test feature so I don't have to rerun the tests all the time by myself.
My meteor application folder structure is like this:
server
foo.coffee
tests
foo.spec.coffee
And with the spec file I want to test code which is located in foo.coffee. I start jasmine-node with this args:
jasmine-node ./ --autotest --coffee --test-dir tests
And now I would assume that the autotest feature will react on all changes in the root folder but it just reacts on changes in the test folder. And I can't start it in the root folder because I get an error in the .meteor files (and I don't want to have jasmine testing/including the meteor code anyway).
So I want to have jasmine rerun the tests even if I change code in the server folder. How can I achieve that?
Use the --watch parameter along with --autotest and specify the directories that contain whatever files you want to have watched.