Is it possible disable the initial execution of the karma test suite such that it is only executed when a watched file changes?
The problem with the initial run in my case is the following.
I am using the jspm development bundling which watches the files included inside the bundle for changes and incrementally rebuilds the bundle if such a change event is emitted.
Since this process runs forever, I cannot wait for it's termination and then launch Karma.
So I'm launching Karma and the bundling in parallel which works great except the initial run where no bundle exists or the bundle potentially contains old sources.
You can try using grunt watch task. It will watch the changes and run the test.
You can search for boilerplate as well.
I just created the npm module called wait-for-change.
Now I can use it inside the package.json like this:
{
"scripts": {
"test": "wait-for-change my-bundle.js && karma start"
},
"devDependencies": {
"wait-for-change": "^1.0.1"
}
}
This works pretty well for me.
Related
For quicker development, I am interested in exposing one of the files of my NEXT.js project as an npm package script. This enables consuming that code in a simple way from the terminal, orchestrate maintenance tasks, etc.
Let's assume the file:
import { Something } from 'some_library';
console.log("Some task to be performed");
And in my package.json:
"scripts": {
"dev": "next dev",
...
"mine": "execute my file" < HERE
},
My first intuition would be calling node directly over my file in the mine task, but this would fail with the following error:
SyntaxError: Cannot use import statement outside a module
I understand the babel transpilation needs to be performed before calling my file, activity that I assume is performed automatically by the dev command.
Is there any way in which I could have my own task that targets code that could be used directly in NEXT.js?. Is there any way to trigger the transpilation and after execute my file?.
Your package is not part of Next.js project and won't be transpilled by Next.js.
You can create a command (npm scripts) that calls Babel to transpile the package and then executes it but it's just confusing. Next.js projects don't include Babel as a root dependency by default, so your package would rely on a module that doesn't explicitly included.
Instead, make the package ready to use in production. Install Babel or another compiler as a dev tool in the package project. Before publishing the package, transpile it to a file that Node.js can execute.
In another words distribute executable files (the package itself) and not just a source of code of the package.
I'm creating my first VS Code extension, but now I stuck while testing my extension automatically.
If I run my automated tests out of VS Code everything works fine, but I want to run the tests also in a continuous integration pipeline which is why the tests should also run if I call them with npm run test.
With npm run test most of my tests run successful, but as far as a test-method depends on the "vscode.executeDefinitionProvider"-output the tests fail, because it does not find any definitions.
await vscode.commands.executeCommand<vscode.Location[]>('vscode.executeDefinitionProvider', document.uri, positionToSearchForSymbols)
.then(definitions => {
if(definitions.length > 0){
//this one is called if I run the tests out of Visual Studio Code
} else{
//this one is called if I run the tests via npm rum test
}
});
Do you have any idea what I'm doing wrong? Why does npm run test behave different than running the tests out of VS Code?
Thanks in advance for your help.
David
Well, I got informed that VS Code sends a message to the language provider (in my case the al language extension) and that the issue has to be on the site of the language provider. Because the issue is not related to VS Code, I will close this question.
You need to setup your test environment to use specific extensions: How do I run integration tests for a vscode extension that depends on other extensions
You need to make sure that the extensions (in your case: DefinitionProvider) are activated before your tests start:
VSCode extension testing: Use `vscode.executeDefinitionProvider` in test
You might run into a situation where nothing of the above works for you. In that case this might help:
https://stackoverflow.com/a/69400358/6702598
I've been using the skeleton navigation skeleton-esnext-webpack environment to run local tests on aurelia. However, sometimes I need to run my tests from a server already set up on the web. I'd like to keep the aurelia plugins intact but not wait so long for the local build to be built and ran since I already have it running elsewhere. The readme doesn't say much about how everything works.
Is there a way to temporarily run my tests while ignoring the local build and setup?
Go the package.json file in the root and modify it as so:
"e2e": "concurrently --success first --kill-others \"npm run e2e:start\"",
You can even keep the original and rename it something else and have that as a local call and rename the above line to run it without building it.
I am using protractor to run End-to-end tests and I was wondering if it was possible to change the locations of where the tests it needs to perform are. I am hoping to be able to pass it in as a command line parameter.
For example this is the current set up:
Protractor currently looks the tests in the path ./tests and then runs the features in the features folder.
I have done a lot of looking around and cannot find where it is defined that this is the path that it uses. I am wanting to be able to pass it a parameter, when run from the command line, along the lines of --params.tests="C:\path\to\tests".
EDIT: I am using Mocha as my test framework
I am assuming you have configured Cucumber as a custom framework in Protractor config file and triggering the tests by running the 'conf.js'
Current Setup might be:
specs: ['tests/features/*.features'],
cucumberOpts: {
// This will point to your dependencies. Script files which contain dependencies
require: 'tests/steps/*.js',
},
Change it to CLI to accept these values at run-time
protractor conf.js --specs tests/features/*.features --cucumberOpts.require tests/steps/*.js
I've used Yeoman to make a quick project skeleton using the yo webapp generator command. In the resulting Gruntfile I see that it's setup to compile CoffeeScript but it seems like its just sticking compiled files in a tmp folder.
coffee: {
dist: {
files: {
'.tmp/scripts/coffee.js': '<%= yeoman.app %>/scripts/*.coffee'
}
},
},
How do these get included in the project during development. I'm not using RequireJS.
The yeoman docs are unclear on how to use coffeescript. They only mention that it gets automatically compiled.
Using yeomen 1.0.0-rc1.4. I use:
$ yo angular --coffee
The resulting project has controller and app scripts in CoffeeScript.
grunt configuration file remains in js (what is not really a problem).
Running
$ grunt test
runs tests and all seems fine.
$ grunt server
is also doing what one expects (build the app, test it, starts server, opens the app in web browser and starts watching for changes, so if I change a coffee script file, it is quickly reflected in the web broser.
Documentation also states, one can use yo to add particular pieces like
angular:controller
angular:directive
angular:filter
angular:route
angular:service
angular:decorator
angular:view
each can be called with a --coffee switch and get the script in CoffeeScript, e.g.:
yo angular:controller user --coffee
I just found an issue in the github repo referencing this problem. https://github.com/yeoman/generator-webapp/issues/12
It offers a temporary solution: https://github.com/yeoman/generator-webapp/issues/12#issuecomment-13731929