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

don't know how to turn this value into a node at valueToNode (node_modules/@babel/types/lib/converters/valueToNode.js:98:9) #263

Closed
AllanOricil opened this issue Feb 3, 2022 · 9 comments

Comments

@AllanOricil
Copy link

AllanOricil commented Feb 3, 2022

Description

I started to have this problem inside Github Actions

image
image

It started 18h ago +-, without any changes to the pipeline, dev dependencies, or even jest config files.
Another weird thing is that I can run all the tests on my machine with no problem. I even did a fresh install to simulate what happens in Github to ensure I was not using cached dependencies.

  1. Deleted lockfile
  2. Cleared the cache with yarn cache clean --all
  3. Deleted /node_modules
  4. installed dependencies with yarn install
  5. ran yarn test:unit and everything worked as expected

So it does not seem to be a problem with the dev dependencies, but I can't determine it for sure. That is why Im here asking for help.

my system info => all tests are executed with no problem

darwin-x64 - m1
node-v14.18.2
yarn-v1.22.10
npm-v6.14.15
sfdx-cli/7.135.0 

github actions info (we are using a docker image based on node:latest)

node-v17.4.0
yarn-v.122.17
npm-v8.3.1
sfd-cli/7.135.0

OBS: None of the following files were changed and the tests started failing. They fail only inside github actions. Locally I can run them without a problem.

jest-setup.js

const { setup } = require('@sa11y/jest');
setup();

global.console = {
    log: console.log,
    error: jest.fn(),
    warn: console.warn,
    info: console.info,
    debug: console.debug,
    table: console.table
};

jest.config.js

const { jestConfig } = require('@salesforce/sfdx-lwc-jest/config');
const setupFilesAfterEnv = jestConfig.setupFilesAfterEnv || [];
setupFilesAfterEnv.push('<rootDir>/jest-setup.js');
module.exports = {
    ...jestConfig,
    testMatch: ['**/salesforce_sfdx/main/default/lwc/**/*.test.js'],
    setupFilesAfterEnv,
    moduleNameMapper: {
        '^@salesforce/apex$': '<rootDir>/salesforce_sfdx/test/jest-mocks/apex',
        '^@salesforce/schema$':
            '<rootDir>/salesforce_sfdx/test/jest-mocks/schema',
        '^lightning/platformShowToastEvent$':
            '<rootDir>/salesforce_sfdx/test/jest-mocks/lightning/platformShowToastEvent',
        '^lightning/messageService$':
            '<rootDir>/salesforce_sfdx/test/jest-mocks/lightning/messageService',
        '^lightning/actions$':
            '<rootDir>/salesforce_sfdx/test/jest-mocks/lightning/actions'
    },
    coveragePathIgnorePatterns: [
        '/node_modules/',
        '/salesforce_sfdx/main/default/lwc/campaignCTATheme',
        '/salesforce_sfdx/main/default/lwc/cfCaseFlexCard',
        '/salesforce_sfdx/main/default/lwc/cfCustomerCard',
        '/salesforce_sfdx/main/default/lwc/cfShowHinStatus',
        '/salesforce_sfdx/main/default/lwc/chatHeader',
        '/salesforce_sfdx/main/default/lwc/chatMessage',
        '/salesforce_sfdx/main/default/lwc/com_debounce',
        '/salesforce_sfdx/main/default/lwc/com_dokobitConnector',
        '/salesforce_sfdx/main/default/lwc/comEmptyState',
        '/salesforce_sfdx/main/default/lwc/comErrorState',
        '/salesforce_sfdx/main/default/lwc/communityLoginPage',
        '/salesforce_sfdx/main/default/lwc/communityLoginPageLex',
        '/salesforce_sfdx/main/default/lwc/comRadioGroup',
        '/salesforce_sfdx/main/default/lwc/comSuccessScreen',
        '/salesforce_sfdx/main/default/lwc/csMarketingAutomation',
        '/salesforce_sfdx/main/default/lwc/csMarketingItem',
        '/salesforce_sfdx/main/default/lwc/csStoryItem',
        '/salesforce_sfdx/main/default/lwc/csTransactional',
        '/salesforce_sfdx/main/default/lwc/cusInvoiceItem',
        '/salesforce_sfdx/main/default/lwc/cusInvoices',
        '/salesforce_sfdx/main/default/lwc/cusMailingListPreferences',
        '/salesforce_sfdx/main/default/lwc/customLabelsService',
        '/salesforce_sfdx/main/default/lwc/ocOfferConfig',
        '/salesforce_sfdx/main/default/lwc/ocOfferGridView',
        '/salesforce_sfdx/main/default/lwc/ocOffersList',
        '/salesforce_sfdx/main/default/lwc/ocOmniStepChart',
        '/salesforce_sfdx/main/default/lwc/ocOmniStepChartItems',
        '/salesforce_sfdx/main/default/lwc/ocShoppingCartSummary',
        '/salesforce_sfdx/main/default/lwc/ocShoppingCartSummaryDisplay',
        '/salesforce_sfdx/main/default/lwc/ocStepWithCartSummary',
        '/salesforce_sfdx/main/default/lwc/preChat',
        '/salesforce_sfdx/main/default/lwc/reportListCmp',
        '/salesforce_sfdx/main/default/lwc/selectNumber',
        '/salesforce_sfdx/main/default/lwc/serSelectAccountAndContact'
    ]
};

package.json

{
    "name": "salesforce-app",
    "private": true,
    "version": "1.0.0",
    "description": "Salesforce App",
    "scripts": {
        "lint": "npm run lint:lwc && npm run lint:aura",
        "lint:aura": "eslint salesforce_sfdx/**/aura/**",
        "lint:lwc": "eslint salesforce_sfdx/**/lwc/**",
        "test": "npm run test:unit",
        "test:unit": "sfdx-lwc-jest",
        "test:unit:watch": "sfdx-lwc-jest --watch",
        "test:unit:debug": "sfdx-lwc-jest --debug",
        "test:unit:coverage": "sfdx-lwc-jest --coverage --skipApiVersionCheck -- --json --coverage",
        "test:unit:coverage:required": "sfdx-lwc-jest --coverage --skipApiVersionCheck -- --json --coverageThreshold='{\"global\":{\"lines\":\"75\"}}' >&2",
        "prettier": "prettier --write \"**/*.{cls,cmp,component,css,html,js,md,page,trigger,xml,yaml,yml}\"",
        "prettier:verify": "prettier --list-different \"**/*.{cls,cmp,component,css,html,js,md,page,trigger,xml,yaml,yml}\"",
        "build:custom-labels-service": "node ./scripts/build_custom_labels_service.js"
    },
    "devDependencies": {
        "@prettier/plugin-xml": "^0.12.0",
        "@sa11y/jest": "^0.4.3",
        "@salesforce/eslint-config-lwc": "^0.7.0",
        "@salesforce/eslint-plugin-aura": "^1.4.0",
        "@salesforce/sfdx-lwc-jest": "^1.0.1",
        "eslint": "^7.6.0",
        "eslint-config-prettier": "^6.11.0",
        "husky": "^4.2.1",
        "lint-staged": "^10.0.7",
        "prettier": "2.3.2",
        "prettier-plugin-apex": "1.10.0",
        "xml-js": "^1.6.11",
        "fs-extra": "^10.0.0",
        "simple-git": "^2.45.1"
    },
    "husky": {
        "hooks": {
            "pre-commit": "npm run build:custom-labels-service && lint-staged"
        }
    },
    "lint-staged": {
        "**/*.{cls,cmp,component,css,html,js,md,page,trigger,xml,yaml,yml}": [
            "prettier --write"
        ],
        "**/{aura|lwc}/**": [
            "eslint"
        ]
    }
}
@AllanOricil
Copy link
Author

AllanOricil commented Feb 3, 2022

some of the Babel packages were patched from .16 to .17

The issue is comming from this package:

https://www.npmjs.com/package/@babel/types

Could it be the cause?

@AllanOricil
Copy link
Author

AllanOricil commented Feb 3, 2022

I was able to reproduce the issue locally with node v14.18.2 or v.17.4.0 so I can say it is not a node version issue, nor a problem with github actions. Also, nor a problem with our repo, since these testss passed on our last merge to our main branch.

image

image

Im almost sure that this update on Babel broke everything.

@nolanlawson
Copy link
Contributor

It looks like your stacktrace has a reference to istanbul as well. If you disable code coverage in your tests (nyc, istanbul, etc.), do the tests pass?

@AllanOricil
Copy link
Author

@nolanlawson I need to upload coverage on codecov.io. so can't disable it.
To fix our issue we installed an old version of babel and it's dependencies after yarn install with
npm install -D @babel/core@7.16.12

Maybe you could force babel core to stay at this version until you make this package compatible with babel 7.17? At the moment I think it is using ^ in the package and this allowed it to be bumped to 7.17 which broke the test.

@nolanlawson
Copy link
Contributor

Could you run yarn why @babel/core? (Or npm ls @babel/core?) I'm not sure which package is depending on @babel/core and causing this problem. (There could be multiple, but one in particular is bringing in that version.)

@lwc/compiler is using a ~ rather than a ^. And I don't see where sfdx-lwc-jest depends on @babel/core.

@AllanOricil
Copy link
Author

image

@nolanlawson
Copy link
Contributor

OK thanks. Yes, it looks like @lwc/jest-transformer depends on @babel/core ^7.16.7: https://github.com/salesforce/lwc-test/blob/531577b24362a857a83d9ed6b14cc2a430308dc5/packages/%40lwc/jest-transformer/package.json#L25

This probably needs some more testing, but it may be an issue with the repo for @lwc/jest-transformer: https://github.com/salesforce/lwc-test

@nolanlawson
Copy link
Contributor

Hm, updating all the dependencies in lwc-test passes the tests: salesforce/lwc-test#146

There is probably some specific combination of dependency versions that's causing this issue.

@pmdartus
Copy link
Member

pmdartus commented Feb 4, 2022

I was able to reproduce the same issue in a fresh SFDX project: https://github.com/pmdartus/sfdx-jest-instanbul-bug.


Update: This is a known jest issue. This issue is caused by babel/babel#14209, breaking Istanbul source map serialization. The Instanbul and Babel teams are currently working on fixing this issue (istanbuljs/istanbuljs#576).

There is, unfortunately, nothing we can do at sfdx-lwc-jest level to fix this issue since it is caused by internal Jest dependencies. Until the Istanbul patch gets released, I would recommend sticking to @babel/core@7.16.X. You could leverage yarn selective resolution to freeze @babel/core version.

@pmdartus pmdartus closed this as completed Feb 4, 2022
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

3 participants