Jest test are failing - unit-testing

Below is issue am getting when I try to run the jest command.
jest --config jest.config.json
FAIL test\Home.spec.js
? Test suite failed to run
SyntaxError: Unexpected reserved word at transformAndBuildScript(node_modules\jest\node_modules\jest-cli\node_modules\jest-runtime\build\transform.js:320:12)
Below is my configuration. Package.json with webpack, jest versions
{
"name": "testjest",
"version": "1.0.0",
"description": "Test React and Redux using Jest",
"main": "index.js",
"license": "MIT",
"scripts": {
"dev": "webpack-dev-server --content-base --inline --hot",
"test": "jest --config jest.config.json"
},
"dependencies": {
"babel-preset-es2015": "^6.18.0",
"babel-preset-react": "^6.16.0",
"babel-preset-stage-0": "^6.16.0",
"react": "^15.4.1",
"react-dom": "^15.4.1",
"react-redux": "^5.0.1",
"redux": "^3.6.0"
},
"devDependencies": {
"babel-core": "^6.26.0",
"babel-jest": "^21.2.0",
"babel-loader": "^6.2.10",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.0",
"core-js": "^2.4.0",
"enzyme": "^2.7.0",
"jest": "^18.1.0",
"json-stable-stringify": "^1.0.1",
"react-addons-test-utils": "^15.4.1",
"react-test-renderer": "^15.4.1",
"redux-mock-store": "^1.2.1",
"regenerator-runtime": "^0.11.0",
"regenerator-transform": "^0.10.0",
"identity-obj-proxy": "3.0.0",
"webpack": "^1.14.0",
"webpack-dev-server": "^1.16.2"
}
}
Here is my jest json config file.
{
"moduleFileExtensions": [
"js",
"jsx"
],
"moduleDirectories": ["node_modules", "bower_components", "shared"],
"moduleNameMapper": {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$":
"<rootDir>/__mocks__/fileMock.js",
"\\.(css|less)$": "<rootDir>/__mocks__/styleMock.js"
},
"testPathIgnorePatterns": [
"<rootDir>/node_modules/",
"<rootDir>/legacy_notes_and_workbook/",
"<rootDir>/src/stylesheets/"
],
"transform": {},
"transformIgnorePatterns": [ "<roodDir>/node_modules/(?!)" , "node_modules/(?!(jest-)?react-native|react-navigation)" ],
"testRegex": "(/__tests__/.*|\\.?(test|spec|Test|Spec))\\.(ts|tsx|js|jsx)$"
}
Node versions installed on my machine are:
node -v
v4.2.2
npm -v
1.4.28
Please let me know if anybody has any solution on above issue. Thanks in advance.

Related

Dependencies aren't being included on the build output of electron forge

My electron app project uses create-react-app and my main process needed the electron-devtools-installer module. I'm using electron-forge for building the app. Now after running npm run make to package and built the app, I'm getting this error message
Error: Cannot find module 'electron-devtools-installer'
after opening the app. I'm not getting this error when I simply run electron ., thus I suspect the module is not being included on the packaging.
Now the said module is for development only, I could simply write a logic to ignore it when in production mode but what happens when I really need a 3rd party modules in my main process in the production, so how do I include the dependencies modules in the packaging?
I moved the electron-devtools-installer mode in dependencies key in package.json but it still doesn't work.
My package.json contains:
{
"name": "myapp",
"version": "0.1.0",
"private": true,
"homepage": ".",
"description": "some description",
"main": "main/init.js",
"author": "anonymouse",
"license": "MIT",
"dependencies": {
"#testing-library/jest-dom": "^5.16.5",
"#testing-library/react": "^13.4.0",
"#testing-library/user-event": "^13.5.0",
"electron-devtools-installer": "^3.2.0",
"electron-squirrel-startup": "^1.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "electron-forge start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"dev": "concurrently -k \"react-scripts start\" \"npm:electron\"",
"electron": "wait-on tcp:3000 && electron .",
"package": "react-scripts build && electron-forge package",
"make": "react-scripts build && electron-forge make",
"clean:winbuild": "rmdir build /s /q & rmdir out /s /q"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"#electron-forge/cli": "^6.0.0-beta.67",
"#electron-forge/maker-deb": "^6.0.0-beta.67",
"#electron-forge/maker-rpm": "^6.0.0-beta.67",
"#electron-forge/maker-squirrel": "^6.0.0-beta.67",
"#electron-forge/maker-zip": "^6.0.0-beta.67",
"concurrently": "^7.4.0",
"dotenv": "^16.0.3",
"electron": "^21.1.1",
"eslint": "^8.25.0",
"eslint-config-google": "^0.14.0",
"eslint-config-standard": "^17.0.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-n": "^15.3.0",
"eslint-plugin-promise": "^6.1.0",
"eslint-plugin-react": "^7.31.10",
"wait-on": "^6.0.1"
},
"config": {
"forge": "./forge.config.js"
}
}
My forge.config.js:
module.exports = {
packagerConfig: {
ignore: [
/coverage.*/,
/node_modules.*/,
/public.*/,
/src.*/,
/\.env|\.gitignore|.*bak|eslint.*|package-lock.*|(?<!build.*)\.txt|(?<!build.*)\.md/
]
},
makers: [
{
name: '#electron-forge/maker-squirrel',
config: {
name: 'bkkgapp'
}
},
{
name: '#electron-forge/maker-zip'
}
]
}

trying to run npm start but getting a port error message

when i'm trying to run "npm start" i'm getting this error message Port "1234" could not be used
enter image description here
see my packege.json
{
"name": "simplefolio",
"version": "1.0.1",
"private": "true",
"description": "A clean, beautiful and responsive portfolio template for Developers!",
"source": "src/index.html",
"scripts": {
"start": "parcel",
"build": "parcel build"
},
"repository": {
"type": "git",
"url": "git+https://github.com/cobidev/simplefolio"
},
"keywords": [],
"author": "Jacobo Martinez",
"license": "ISC",
"bugs": {
"url": "https://github.com/cobidev/simplefolio/issues"
},
"homepage": "https://github.com/cobidev/simplefolio#readme",
"devDependencies": {
"#parcel/transformer-sass": "^2.0.1",
"parcel": "^2.0.1",
"prettier": "^2.4.1"
},
"dependencies": {
"#popperjs/core": "^2.10.2",
"bootstrap": "^5.1.3",
"jquery": "^3.6.0",
"popper.js": "^1.16.1",
"vanilla-tilt": "^1.7.2"
}
}
Do you have VLC running on your computer? It might be using that port: https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers
Can you try to use a different port?

Storybook - Ember.js - Getting stuck on loading state

I've installed storybook/ember on an existing Ember project, but unfortunatelly it stuck on loading screen with no error - doesn't display the welcome page and shows the spinner instead.
.storybook/main.js
module.exports = {
"stories": [
"../stories/**/*.stories.mdx",
"../stories/**/*.stories.#(js|jsx|ts|tsx)"
],
"addons": [
"#storybook/addon-links",
"#storybook/addon-essentials"
]
}
I haven't touched anything in the stories or .storybook (everythins is the default).
package.json
{
"name": "web-ui",
"version": "0.0.0",
"description": "Small description for web-ui goes here",
"repository": "",
"license": "MIT",
"author": "",
"directories": {
"doc": "doc",
"test": "tests"
},
"private": true,
"scripts": {
"build": "ember build",
"lint:hbs": "ember-template-lint .",
"lint:js": "eslint .",
"start": "ember serve",
"test": "ember test -r xunit",
"coverage": "COVERAGE=true ./node_modules/.bin/ember test --silent",
"storybook": "start-storybook -p 6006 -s dist",
"build-storybook": "build-storybook -s dist"
},
"engines": {
"node": ">= 10.*"
},
"devDependencies": {
"#babel/core": "7.11.6",
"#ember/jquery": "1.1.0",
"#ember/optional-features": "2.0.0",
"#glimmer/component": "1.0.1",
"#storybook/addon-actions": "^6.0.22",
"#storybook/addon-essentials": "^6.0.22",
"#storybook/addon-links": "^6.0.22",
"#storybook/ember": "^6.0.22",
"acorn": "^8.0.1",
"babel-eslint": "10.1.0",
"babel-loader": "^8.1.0",
"babel-plugin-ember-modules-api-polyfill": "^3.1.1",
"babel-plugin-htmlbars-inline-precompile": "^4.2.0",
"bootstrap": "3.4.1",
"broccoli-asset-rev": "3.0.0",
"broccoli-funnel": "3.0.3",
"broccoli-merge-trees": "4.2.0",
"browser": "0.2.6",
"d3": "6.1.1",
"ember-ajax": "5.0.0",
"ember-auto-import": "1.6.0",
"ember-can": "3.0.0",
"ember-cli": "3.16.0",
"ember-cli-app-version": "3.2.0",
"ember-cli-babel": "7.22.1",
"ember-cli-code-coverage": "1.0.0",
"ember-cli-content-security-policy": "1.1.1",
"ember-cli-dependency-checker": "3.2.0",
"ember-cli-document-title-northm": "1.0.3",
"ember-cli-htmlbars": "5.3.1",
"ember-cli-inject-live-reload": "2.0.2",
"ember-cli-json-module": "1.0.0",
"ember-cli-jstree": "1.0.12",
"ember-cli-less": "3.0.1",
"ember-cli-mirage": "1.1.8",
"ember-cli-nouislider": "1.2.1",
"ember-cli-pagination": "3.1.5",
"ember-cli-sri": "2.1.1",
"ember-cli-template-lint": "1.0.0-beta.3",
"ember-cli-test-loader": "3.0.0",
"ember-cli-uglify": "3.0.0",
"ember-data": "3.16.0",
"ember-diff-attrs": "0.2.2",
"ember-disable-proxy-controllers": "1.0.2",
"ember-export-application-global": "2.0.1",
"ember-flatpickr": "2.16.2",
"ember-infinity": "2.1.2",
"ember-inflector": "3.0.1",
"ember-inline-svg": "1.0.0",
"ember-intl": "5.4.2",
"ember-load-initializers": "2.1.1",
"ember-math-helpers": "2.15.0",
"ember-maybe-import-regenerator": "0.1.6",
"ember-power-select": "3.0.4",
"ember-qunit": "4.6.0",
"ember-radio-button": "2.0.1",
"ember-resolver": "7.0.0",
"ember-simple-auth": "2.1.1",
"ember-source": "3.16.0",
"ember-storage": "2.0.0",
"ember-table": "2.2.3",
"ember-template-lint": "1.13.2",
"ember-tooltips": "3.4.5",
"ember-truth-helpers": "2.1.0",
"ember-vega": "1.1.5",
"emberx-select": "3.1.1",
"eslint": "5.16.0",
"eslint-plugin-ember": "7.7.2",
"eslint-plugin-node": "11.1.0",
"jquery-mockjax": "2.6.0",
"jshint": "2.12.0",
"json-merger": "1.1.2",
"loader.js": "4.7.0",
"material-design-icons-iconfont": "4.0.5",
"minimatch": "3.0.4",
"node-gyp": "6.0.0",
"qunit-dom": "1.5.0",
"react-is": "^16.13.1",
"request": "2.88.2",
"rsvp": "4.8.5",
"valid-url": "1.0.9",
"vega-lib": "4.4.0",
"yaml-lint": "1.2.4"
},
"dependencies": {
"#ember/test-helpers": "^1.7.2",
"#storybook/core": "^6.0.22",
"core-js": "^3.6.5",
"faker": "^4.1.0",
"global": "^4.4.0",
"regenerator-runtime": "^0.13.7",
"semver": "^6.3.0",
"ts-dedent": "^2.0.0"
}
}
Any help/suggestions are appreciated.
You need to make sure to run ember install #storybook/ember-cli-storybook after running npx sb init, this will make sure that the ember adapter is installed.
Once you've made thoses steps, make sure to first run your ember app (ie ember s nor ember build) then once the app is built, you can run storybook as you've done.
This is due to a limitation because today the install steps are a bit broken and need to be fixed, that's why we need to run thoses extra steps!
Let me know if you got any questions :)

travis running my tests against different versions of ember

I have this repo which uses ember 1.11.0.
My bower.json looks like this:
{
"name": "emberx-autosuggest",
"dependencies": {
"ember": "1.11.1",
"ember-cli-shims": "ember-cli/ember-cli-shims#0.0.3",
"ember-cli-test-loader": "ember-cli-test-loader#0.1.3",
"ember-data": "1.0.0-beta.16.1",
"ember-load-initializers": "ember-cli/ember-load-initializers#0.1.4",
"ember-qunit": "0.3.1",
"ember-qunit-notifications": "0.0.7",
"ember-resolver": "~0.1.15",
"jquery": "^1.11.1",
"loader.js": "ember-cli/loader.js#3.2.0",
"qunit": "~1.17.1"
}
}
My tests all pass locally but when I push to github, travis appears to be running my tests against ember 1.10.0, 1.11.0 and 1.12.0-beta.1.
I only want to run against 1.11.0, how can I configure travis to do this?
My travis.yml looks like this:
---
language: node_js
node_js:
- "0.12"
sudo: false
cache:
directories:
- node_modules
before_install:
- "npm config set spin false"
- "npm install -g npm#^2"
install:
- npm install -g bower
- npm install
- bower install
script:
- npm test
My package.json looks like this:
{
"name": "emberx-autosuggest",
"version": "0.0.1",
"description": "Tag picker functionality",
"directories": {
"doc": "doc",
"test": "tests"
},
"scripts": {
"start": "ember server",
"build": "ember build",
"test": "ember try:testall"
},
"repository": "https://github.com/dagda1/emberx-autosuggest.git",
"engines": {
"node": ">= 0.10.0"
},
"author": "",
"license": "MIT",
"devDependencies": {
"broccoli-asset-rev": "^2.0.2",
"ember-cli": "0.2.3",
"ember-cli-app-version": "0.3.3",
"ember-cli-content-security-policy": "0.4.0",
"ember-cli-dependency-checker": "0.0.8",
"ember-cli-ic-ajax": "0.1.1",
"ember-cli-inject-live-reload": "^1.3.0",
"ember-cli-qunit": "0.3.10",
"ember-cli-uglify": "1.0.1",
"ember-data": "1.0.0-beta.16.1",
"ember-export-application-global": "^1.0.2",
"ember-disable-prototype-extensions": "^1.0.0",
"ember-try": "0.0.4"
},
"keywords": [
"ember-addon"
],
"dependencies": {
"ember-cli-htmlbars": "0.7.4",
"ember-cli-babel": "^5.0.0"
},
"ember-addon": {
"configPath": "tests/dummy/config"
}
}
Uninstall ember-try, or edit config/ember-try.js to test only the versions of ember you would like.

Nested addon CSS not merged into vendor.css

I have an addon, my-addon-parent, that depends on a nested addon, my-addon-nested, that specified via the the dependencies property in my-addon-parent's package.json.
When I run the dummy app for my-addon-parent, the nested addon's CSS is imported correctly (I use the included hook to specify the import) and added to the vendor.css file.
However, when including my-addon-parent in an Ember app, the nested addons CSS is not added to the vendor.css file. Is there a hook/setting that I am missing? Below are the package.json for the app and the respective index.js files for the parent and nested addons.
Ember App package.json
{
"name": "my-app",
"version": "0.0.0",
"description": "My App.",
"private": true,
"directories": {
"doc": "doc",
"test": "tests"
},
"scripts": {
"start": "ember server",
"build": "ember build",
"test": "ember test"
},
"repository": "",
"engines": {
"node": ">= 0.10.0"
},
"author": "",
"license": "MIT",
"devDependencies": {
"broccoli-asset-rev": "^2.0.0",
"connect-restreamer": "^1.0.1",
"ember-cli": "0.2.0",
"ember-cli-app-version": "0.3.2",
"ember-cli-babel": "^4.0.0",
"ember-cli-content-security-policy": "0.3.0",
"ember-cli-dependency-checker": "0.0.8",
"ember-cli-htmlbars": "0.7.4",
"ember-cli-ic-ajax": "0.1.1",
"ember-cli-inject-live-reload": "^1.3.0",
"ember-cli-qunit": "0.3.9",
"ember-cli-uglify": "1.0.1",
"ember-data": "1.0.0-beta.15",
"ember-export-application-global": "^1.0.2",
"express": "^4.12.3",
"glob": "^4.5.3",
"morgan": "^1.5.2",
"my-addon-parent": "some/location"
}
}
my-addon-parent index.js
/* jshint node: true */
'use strict';
module.exports = {
name: 'my-addon-parent',
included: function (app) {
this._super.included(app);
app.import('vendor/my-addon-parent/my-addon-parent.css');
}
};
my-addon-nested index.js
/* jshint node: true */
'use strict';
module.exports = {
name: 'my-addon-nested',
included: function (app) {
this._super.included(app);
app.import('vendor/my-addon-nested/my-addon-nested.css');
}
};
This is currently not possible. Details here.