Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected token 'export' #10766

Closed
ravivit9 opened this issue Dec 23, 2021 · 9 comments
Closed

Unexpected token 'export' #10766

ravivit9 opened this issue Dec 23, 2021 · 9 comments
Assignees

Comments

@ravivit9
Copy link

ravivit9 commented Dec 23, 2021

Description

After installing latest version of the package I started getting the below error during ng test.
SyntaxError: Unexpected token 'export'

  • igniteui-angular version:
  • browser: Chrome

`{
  "name": "workspace",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "nx",
    "postinstall": "node ./decorate-angular-cli.js && ngcc --properties es2015 browser module main --first-only --create-ivy-entry-points",
    "nx": "nx",
    "start": "nest start --debug --watch",
    "hmr": "ng serve --configuration hmr",
    "build": "ng build --aot --configuration production",
    "build:dev": "nx build --aot -c=dev",
    "test": "ng test",
    "lint": "nx workspace-lint && ng lint",
    "e2e": "ng e2e",
  },
  "private": true,
  "dependencies": {
    "@agm/core": "^3.0.0-beta.0",
    "@agm/markerclusterer": "^3.0.0-beta.0",
    "@angular/animations": "12.2.15",
    "@angular/cdk": "^11.2.12",
    "@angular/common": "12.2.15",
    "@angular/compiler": "12.2.15",
    "@angular/core": "12.2.15",
    "@angular/forms": "12.2.15",
    "@angular/platform-browser": "12.2.15",
    "@angular/platform-browser-dynamic": "12.2.15",
    "@angular/router": "12.2.15",
    "@fortawesome/fontawesome-free": "^5.15.3",
    "@google/markerclustererplus": "^5.1.3",
    "@nestjs/common": "^7.6.15",
    "@nestjs/core": "^7.6.15",
    "@nestjs/jwt": "^7.2.0",
    "@nestjs/mongoose": "^7.2.4",
    "@nestjs/platform-express": "^7.6.15",
    "@ng-bootstrap/ng-bootstrap": "^9.1.0",
    "@ngx-pwa/local-storage": "^11.1.0",
    "@nrwl/angular": "12.7.2",
    "@types/bluebird": "^3.5.34",
    "@types/chart.js": "^2.9.31",
    "@types/jsonwebtoken": "^8.5.1",
    "@types/sequelize": "^4.28.10",
    "@types/validator": "^13.1.3",
    "agm-direction": "^0.8.9",
    "agm-overlays": "^2.0.0",
    "angular-bootstrap-md": "^11.1.0",
    "animate.css": "^4.1.1",
    "aws-sdk": "^2.905.0",
    "aws-sns-sms": "^1.0.2",
    "bcrypt": "^5.0.1",
    "bootstrap": "^5.0.0",
    "canvas": "^2.8.0",
    "chart.js": "^2.9.4",
    "crypto": "^1.0.1",
    "crypto-js": "^4.0.0",
    "hammerjs": "^2.0.8",
    "igniteui-angular": "^11.1.10",
    "jsonwebtoken": "^8.5.1",
    "jwt-decode": "^3.1.2",
    "libphonenumber-js": "^1.9.17",
    "mon": "0.0.8",
    "mongoose": "^5.12.8",
    "mysql2": "^2.3.3",
    "ng-pick-datetime": "^7.0.0",
    "ng2-charts": "^2.4.2",
    "ngx-auto-unsubscribe": "^3.0.1",
    "ngx-charts": "^3.0.2",
    "ngx-connection-service": "^7.0.3",
    "ngx-doc-viewer": "^2.0.2",
    "ngx-light-carousel": "^1.1.10",
    "ngx-material-timepicker": "^5.5.3",
    "ngx-snackbar": "^2.0.1",
    "ngx-swiper-wrapper": "^10.0.0",
    "node-gyp": "^8.0.0",
    "nodemailer": "^6.6.0",
    "otp-generator": "^2.0.0",
    "reflect-metadata": "^0.1.13",
    "rxjs": "~7.0.1",
    "sequelize": "^6.12.2",
    "sequelize-cli": "^6.3.0",
    "sequelize-typescript": "^2.1.1",
    "stream": "0.0.2",
    "swiper": "^6.6.1",
    "tslib": "^2.2.0",
    "zone.js": "~0.11.4"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "12.2.14",
    "@angular-eslint/eslint-plugin": "12.3.1",
    "@angular-eslint/eslint-plugin-template": "12.3.1",
    "@angular-eslint/template-parser": "12.3.1",
    "@angular/cli": "12.2.14",
    "@angular/compiler-cli": "12.2.15",
    "@angular/language-service": "12.2.15",
    "@angularclass/hmr": "^3.0.0",
    "@compodoc/compodoc": "^1.1.14",
    "@nestjs/schematics": "^7.3.1",
    "@nestjs/testing": "^7.6.15",
    "@nrwl/cli": "12.7.2",
    "@nrwl/cypress": "12.7.2",
    "@nrwl/eslint-plugin-nx": "12.7.2",
    "@nrwl/jest": "12.7.2",
    "@nrwl/linter": "12.7.2",
    "@nrwl/nest": "12.7.2",
    "@nrwl/node": "12.7.2",
    "@nrwl/nx-cloud": "12.3.10",
    "@nrwl/tao": "12.7.2",
    "@nrwl/workspace": "12.7.2",
    "@types/crypto-js": "^4.0.1",
    "@types/cryptr": "^4.0.1",
    "@types/googlemaps": "^3.43.3",
    "@types/jest": "26.0.23",
    "@types/mongoose": "^5.10.5",
    "@types/node": "15.0.2",
    "@types/swiper": "^5.4.2",
    "@typescript-eslint/eslint-plugin": "4.28.5",
    "@typescript-eslint/parser": "4.28.5",
    "codelyzer": "6.0.2",
    "cypress": "^7.3.0",
    "dotenv": "10.0.0",
    "eslint": "7.26.0",
    "eslint-config-prettier": "8.3.0",
    "husky": "^6.0.0",
    "jest": "27.0.3",
    "jest-preset-angular": "9.0.3",
    "prettier": "2.3.2",
    "pretty-quick": "^3.1.0",
    "sass-lint": "^1.13.1",
    "scss-lint": "0.0.0",
    "ts-jest": "27.0.3",
    "ts-node": "9.1.1",
    "tslint": "6.1.3",
    "tslint-config-prettier": "^1.18.0",
    "typescript": "4.3.5"
  },
  "browser": {
    "crypto": false
  },
  },
  "jest": {
    "verbose": true,
    "transformIgnorePatterns": [
      "<rootDir>/node_modules/(?!lodash-es)"
    ]
  }
}
`

Steps to reproduce

  1. Upgraded latest version of "igniteui-angular": "^11.1.10"
  2. ng test

Result

What is the actual result after following the steps to reproduce?
SyntaxError: Unexpected token 'export'

  at Runtime.createScriptFromCode (../../node_modules/jest-runtime/build/index.js:1728:14)
  at ../../node_modules/igniteui-angular/bundles/igniteui-angular.umd.js:2:364
  at Object.<anonymous> (../../node_modules/igniteui-angular/bundles/igniteui-angular.umd.js:5:2)

Test Suites: 6 failed, 1 skipped, 14 passed, 20 of 21 total
Tests: 1 failed, 1 skipped, 14 passed, 16 total

Expected result

What is the expected result after following the steps to reproduce?
All tests must passed

Attachments

Attach a sample if available, and screenshots, if applicable.

@hanastasov
Copy link
Contributor

Hi @ravivit9, I see that your app uses version 12 of Angular. Please go ahead and update igniteui-angular library to version 12.3.7 and let me know if error still occurs.

@hanastasov hanastasov self-assigned this Jan 5, 2022
@mikerentmeister
Copy link

@hanastasov I'm using Angular 13.1.3 with igniteui-angular 13.0.11. I am using a standard Nx repo lib. I am trying to unit test a simple component with only an igx-input-group and igxInput inside. I get this error:

image

When I open up that file, the line it highlights is this one dealing with icons:
image

Here's my package.json for reference:

{
  "name": "experlogix-client",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "nx",
    "postinstall": "node ./decorate-angular-cli.js && ngcc --properties esm2015",
    "start-ds": "nx serve design-studio --public-host avysta.design.cpq.experlogixlocal.com",
    "start-ac": "nx serve admin-center --public-host admin.cpq.experlogixlocal.com",
    "start-pd": "nx serve process-designer --public-host processdesigner.cpq.experlogixlocal.com",
    "build": "nx build",
    "lint": "npx stylelint {apps/design-studio,apps/admin-center,apps/process-designer,libs}/**/*.scss && yarn lint-all",
    "lint-all": "nx run-many --all --target=lint",
    "test": "nx test",
    "test-all": "nx run-many --all --target=test"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^13.1.2",
    "@angular/cdk": "^13.1.2",
    "@angular/common": "~13.1.2",
    "@angular/compiler": "~13.1.2",
    "@angular/core": "~13.1.2",
    "@angular/elements": "13.1.2",
    "@angular/forms": "~13.1.2",
    "@angular/localize": "13.1.2",
    "@angular/material": "^13.1.2",
    "@angular/platform-browser": "~13.1.2",
    "@angular/platform-browser-dynamic": "~13.1.2",
    "@angular/pwa": "^0.1100.3",
    "@angular/router": "~13.1.2",
    "@angular/service-worker": "~13.1.2",
    "@igniteui/material-icons-extended": "^2.10.0",
    "@microsoft/applicationinsights-web": "^2.5.7",
    "@microsoft/signalr": "^5.0.5",
    "@nrwl/angular": "13.4.6",
    "@rxweb/reactive-form-validators": "^2.1.6",
    "@w11k/ngx-componentdestroyed": "^5.0.2",
    "@webcomponents/custom-elements": "^1.4.3",
    "d3": "^6.3.0",
    "devextreme": "21.2",
    "devextreme-angular": "21.2",
    "hammerjs": "^2.0.8",
    "igniteui-angular": "^13.0.11",
    "jszip": "^3.7.1",
    "material-design-icons": "^3.0.1",
    "monaco-editor": "^0.24.0",
    "oidc-client": "^1.10.1",
    "platform": "^1.3.6",
    "rxjs": "~6.6.2",
    "tslib": "^2.3.1",
    "zone.js": "~0.11.4"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~13.1.3",
    "@angular-eslint/builder": "~12.6.1",
    "@angular-eslint/eslint-plugin": "~12.6.1",
    "@angular-eslint/eslint-plugin-template": "~12.6.1",
    "@angular-eslint/template-parser": "~12.6.1",
    "@angular/cli": "~13.1.3",
    "@angular/compiler-cli": "^13.1.2",
    "@angular/language-service": "^13.1.2",
    "@babel/preset-typescript": "^7.16.7",
    "@igniteui/angular-schematics": "~13.0.900",
    "@nrwl/cli": "13.4.6",
    "@nrwl/cypress": "13.4.6",
    "@nrwl/eslint-plugin-nx": "13.4.6",
    "@nrwl/jest": "13.4.6",
    "@nrwl/linter": "13.4.6",
    "@nrwl/tao": "13.4.6",
    "@nrwl/workspace": "13.4.6",
    "@types/d3": "^6.2.0",
    "@types/hammerjs": "^2.0.40",
    "@types/jest": "27.0.2",
    "@types/node": "14.14.33",
    "@types/platform": "^1.3.4",
    "@typescript-eslint/eslint-plugin": "^5.3.0",
    "@typescript-eslint/eslint-plugin-tslint": "^5.3.0",
    "@typescript-eslint/parser": "^5.3.0",
    "cypress": "^8.3.0",
    "eslint": "7.32.0",
    "eslint-config-prettier": "8.1.0",
    "eslint-formatter-azure-devops": "^0.2.0",
    "eslint-plugin-cypress": "^2.10.3",
    "eslint-plugin-deprecation": "^1.2.0",
    "eslint-plugin-import": "^2.22.1",
    "eslint-plugin-jsdoc": "^32.2.0",
    "eslint-plugin-prefer-arrow": "^1.2.3",
    "jest": "27.2.3",
    "jest-preset-angular": "11.0.0",
    "ng-packagr": "^13.1.2",
    "postcss": "^8.0.0",
    "postcss-import": "^14.0.2",
    "postcss-preset-env": "^6.7.0",
    "postcss-url": "^10.1.1",
    "prettier": "^2.3.1",
    "stylelint": "^14.0.0",
    "stylelint-config-standard-scss": "^2.0.1",
    "ts-jest": "27.0.5",
    "typescript": "~4.4.4"
  }
}

@Aleksandyr
Copy link
Contributor

@mikerentmeister I couldn't reproduce your issue with the same version.
Can you please adjust the attached sample and send it back to me?

@Aleksandyr Aleksandyr added 🛠️ status: in-development Issues and PRs with active development on them and removed 🆕 status: new labels Feb 16, 2022
@Aleksandyr
Copy link
Contributor

@mikerentmeister If we can't reproduce that. We are going to close this issue in one week time.

@mikerentmeister
Copy link

My team was able to repro it today right before the end of our work day, using your attached sample. We will get it posted here on Monday

@hanastasov hanastasov removed the 🛠️ status: in-development Issues and PRs with active development on them label Feb 28, 2022
@mikerentmeister
Copy link

mikerentmeister commented Feb 28, 2022

Here is the reproduction of the error mentioned above:
export-error.zip

You should just be able to install the dependencies, then run npm start

Edit:
Some additional context: In our apps we have wrapper components around every 3rd party control that we reference, so that if we ever have to swap out libraries, it's a bit easier. That's why there is an app-input component in the first place.

@Aleksandyr
Copy link
Contributor

@mikerentmeister I suspect that the problem is comming from the jest itself.
I tried setting up jest in an entirely new project and saw that there was some issues logged with that indetical problem.
I've managed to reproduce that same issue without including IG component.

test-jest.zip

With that in mind I don't think we have something to do here.

@mikerentmeister
Copy link

@Aleksandyr Thank you for your response.

Based on this comment I modified my transformIgnorePatterns to just 1 item in the array, and tests started to run for us. I think we can probably close this issue. If anyone comes here in the future, this is our current pattern in our jest.config.js:

transformIgnorePatterns: ['node_modules/(?!@ngrx|@angular|rxjs|igniteui-angular|@igniteui/material-icons-extended)']

@hanastasov
Copy link
Contributor

Thanks for sharing the solution, @mikerentmeister!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants