I would like to display Spectron test results in TeamCity. I have followed the instructions at the Webdriverio TeamCity Reporter page, which are:
npm install wdio-teamcity-reporter --save-dev
and creating a wdio.conf.js file:
exports.config = {
reporters: ['teamcity'],
}
I have placed this file at the top of the project. It has no other entries; I've never needed it before.
I have also tried the additional configuration suggested at wdio-teamcity-reporter npm page.
This is the Jest object in package.json:
"jest": {
"moduleFileExtensions": [
"ts",
"tsx",
"js"
],
"transform": {
"\\.(ts|tsx)$": "<rootDir>/node_modules/ts-jest/preprocessor.js"
},
"roots": [
"<rootDir>/__tests__/",
"<rootDir>/components/"
],
"modulePaths": [
"<rootDir>/__tests__/",
"<rootDir>/components/"
],
"testMatch": [
"**/?(*.)(spec|test).(ts)?(x)"
]
}
And this is the relevant command (that TeamCity calls) in package.json:
"scripts": {
// ...
"test": "jest --maxWorkers=1 --forceExit",
// ...
},
This testing project is built with Typescript and Jest, and only comprises the e2e Spectron tests for an Electron app. The build artifact for that app is a TeamCity dependency for my test 'build'. In my build, TeamCity installs the app, runs the Spectron tests (which are passing), and then uninstalls the app.
All I can see at the moment is the Jest console output within the build log. While there are some hidden artifacts, I see no normal artifacts. I was thinking that the reporting package should have produced an html artifact. How do I go about displaying a test tab, or some other useful set of results?
It turns out that Jest can collect all the Webdriver results. Try using https://www.npmjs.com/package/jest-teamcity.
In jest.config.js use:
"testResultsProcessor": "jest-teamcity"
Related
vite build uses esbuild to transform both the package dependencies (node modules) as well as the app source code into the target JavaScript specification, i.e. es2015.
I observe that vite/esbuild re-transform the entire sources in ./node_modules every time vite build is run.
How can this build stack be used to keep and reuse the previously transformed files, at least for the entire ./node_modules folder (given dependencies didn't change of course) so that subsequent vite build command invocations run significantly faster?
One way to improve the performance of subsequent Vite build command invocations is by using a caching mechanism. You can use a caching tool such as cache-loader or hard-source-webpack-plugin to cache the transpilation results of the node modules.
This will allow Vite to reuse the previously transpiled files for the node modules, as long as the dependencies haven't changed.
This can greatly speed up the build process.
You can also try to configure esbuild to only transpile the changed files instead of the entire codebase using the -w or --watch option when running the esbuild command. This option tells esbuild to watch the input files and only transpile the files that have been modified.
In Vite, you can configure the esbuild plugin to use the --watch option by adding the following to your vite.config.js file:
const esbuildConfig = {
watch: true,
};
module.exports = {
esbuild: esbuildConfig,
};
Examples :
cache-loader:
Install the package:
npm install cache-loader --save-dev
In your vite.config.js file, configure the cache-loader to be used for transpiling the node modules by adding it as a rule in the build object:
module.exports = {
build: {
...
css: {
...
},
js: {
...
loaderOptions: {
cache: true,
cacheDirectory: 'node_modules/.cache'
}
},
...
}
}
Run your build command ( vite build )
hard-source-webpack-plugin:
install the package:
npm install hard-source-webpack-plugin --save-dev
In your vite.config.js file, import the plugin and add it to the build.plugins array:
const HardSourceWebpackPlugin = require('hard-source-webpack-plugin');
module.exports = {
build: {
...
plugins: [
new HardSourceWebpackPlugin()
],
...
}
}
Run your build command (vite build)
These examples, as you asked in your comment, are for Vite versions 2.5.8 and 3.x. However, in order to use them with Vite 3.x you need to update the build config to match the new format.
Please don't hesitate to write a comment if you still have a problem or questions!
I just started using async/await in my nodejs code, and noticed that my code coverage tool cannot handle it, I get "Fatal error: Unexpected token" for any lines with async on them. I'm using karma and jasmine as my unit test framework, and grunt-jasmine-node-coverage for code coverage. I checked and grunt-jasmine-node-coverage hasn't been updated in years. I looked for a more modern code coverage library and couldn't find any that had been updated in the past year. I'm fine with using just npm instead of grunt to run my tasks, I know I'm way behind on that, but I couldn't find any code coverage frameworks recent enough that I think that would make a difference.
Does anyone know of a code coverage framework for JS code that works with ES2018 syntax?
I used nyc (https://github.com/istanbuljs/nyc) with jasmine (https://jasmine.github.io/pages/docs_home.html) and it worked great. My package.json config was:
"scripts": {
"test":"jasmine",
"coverage": "nyc --reporter=lcov npm run test"
},
"nyc": {
"report-dir": "spec/coverage",
"exclude": [
"spec/**/*"
]
},
Here's the scenario:
We want a monorepo for several components and would like to use lerna with yarn workspaces for it.
To ensure no problems happen with semantic versioning, it would be nice to have code reviews for the version numbers as well.
So the package.json defines a version-bump script that shall only be used to increment package versions.
After the tests running and CR being OK, we'd like a deploy bot to publish the packages to our custom registry for us.
For this it would be nice to use lerna publish --skip-git, so that lerna would publish the changed packages only.
The problem here is that lerna publish won't just publish the packages, but asks for their version increments again.
It would be nice to know of an option or workaround to publish without incrementing the version.
Our current workaround is to use lerna exec npm publish, but this will try to publish already published packages again. We also cannot use lerna exec yarn publish because in that case yarn asks for version increments.
The setup looks like this:
lerna.json:
{
"lerna": "2.5.1",
"version": "independent",
"npmClient": "yarn",
"useWorkspaces": true,
"packages": [
"packages/*"
]
}
package.json
{
"name": "…",
"version": "0.0.0",
"description": "…",
"main": "index.js",
"repository": {
"type": "git",
"url": "…"
},
"workspaces": [
"packages/*"
],
"private": true,
"scripts": {
"version-bump": "./node_modules/lerna/bin/lerna.js publish --skip-npm",
"test": "echo well tested"
},
"devDependencies": {
"lerna": "^2.5.1"
}
}
For anyone that needs this functionality, it looks like they're working on it for v3.0:
Separate "version" and "publish" commands - https://github.com/lerna/lerna/issues/961
I'm in the same boat. The feature doesn't exist. Ideally Lerna would have an argument you could pass to skip bumping the version numbers. You're best making some noise over at the project on Github: https://github.com/lerna/lerna/issues
Using the latest version of Nativescript I've created a plugin as per the documentation and after running tns plugin add ../nativescript-keychain I get the message Successfully installed plugin nativescript-keychain.
I can also see that it's been added to the node_modules directory of my app but require("nativescript-keychain") doesn't work as I get the error Cannot find module 'nativescript-keychain'
My plugin package.json looks like
{
"name": "nativescript-keychain",
"version": "0.0.1",
"nativescript": {
"platforms": {
"ios": "2.2.1"
}
}
}
There are several reasons why this might occur; it would be helpful if you provided a repo to see all the code.
package.json doesn't have a link to the source, typically you have a main: "somefile" key.
Did you do tns run ios --emulator after you installed the plugin, you have to rebuild the app before it will take effect, plugins can't be synced via livesync...
Is the code TypeScript or JavaScript, if it is TypeScript it needs to be transpiled to JS before you can add it to your demo application. TNS will NOT compile any TS code in the plugins. Plugins have to ship with the final JS code.
You need typings for TS to use the auto-complete and not throw warnings about what methods are available.
I have a project.json script for 'prepare' that runs a gulpfile to push my bower stuff into the wwwroot. Works great, except during dev I have to manually run it after I update the bower.json package. Any way to automate this during dev? I'd normally use a post-build script but they are no where to be seen. My project.json scripts are looks like this:
"scripts": {
"prepare": [ "gulp bower" ]
}
What i'd love is:
"scripts": {
"post-build": [ "gulp bower" ]
}
You can use the Task Runner Explorer to automate this. (Use the Quick Launch in the upper right, Ctrl+Alt+\, or View->Other Windows->Task Runner Explorer.)
Find the task you want to add (bower or prepare, depending on the route you want to go), right click, and use the context menu to add the bindings.
My gruntfile.js, for example, got the following line added to the top:
/// <binding BeforeBuild='beforeBuild' AfterBuild='afterBuildMinimal' ProjectOpened='watch' />
I'm not certain if the gulpfile.js uses the exact same conventions, but the Task Runner Explorer is the way to go, either way!
there's postrestore and postbuild you can use on project.json.
I use it like this :
"postrestore": [ "npm install", "bower install" ]
"postbuild": [ "brunch build" ]
in your example, I think you want
"postbuild": [ "gulp bower" ]