salesforce / sfdx-lwc-jest

Run Jest against LWC components in SFDX workspace environment
MIT License
165 stars 82 forks source link

All test suites failed to run since 1.0.0 #239

Closed alanjaouen closed 3 years ago

alanjaouen commented 3 years ago

Description

Since Release 1.0.0, none of my tests pass, there is an exemple with a really simple one

Steps to Reproduce

// simplified test case
it('Component rendered', () => {
        const element = createElement('c-info-GSL', {
            is: InfoGSL
        });
        document.body.appendChild(element);

        expect(element.shadowRoot.querySelector("lightning-record-view-form")).not.toBeNull();
    });
<!-- HTML for component under test -->
<template>
    <div class="acc-container">
        <lightning-record-view-form record-id={recordId} object-api-name="Account">
            <div class="slds-grid">
                <div class="slds-col slds-size_1-of-2">
                    <lightning-output-field field-name="ID_SL__c"></lightning-output-field>
                </div>
                <div class="slds-col slds-size_1-of-2">
                    <lightning-output-field field-name="Price__c"></lightning-output-field>
                </div>
            </div>
        </lightning-record-view-form>
    </div>
</template>
// JS for component under test
import { LightningElement,api } from 'lwc';

export default class AccInfoGSL extends LightningElement {
    @api recordId;
}
// Jest config overrides (if any)
# Command to repro
sfdx-lwc-jest -- --no-cache

Expected Results

pass

Actual Results

TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined

      at Object.getCacheKey (node_modules/@lwc/jest-transformer/src/index.js:116:14)
      at ScriptTransformer._getCacheKey (node_modules/@jest/transform/build/ScriptTransformer.js:280:41)
      at ScriptTransformer._getFileCachePath (node_modules/@jest/transform/build/ScriptTransformer.js:351:27)
      at ScriptTransformer.transformSource (node_modules/@jest/transform/build/ScriptTransformer.js:588:32)
      at ScriptTransformer._transformAndBuildScript (node_modules/@jest/transform/build/ScriptTransformer.js:758:40)
      at ScriptTransformer.transform (node_modules/@jest/transform/build/ScriptTransformer.js:815:19)

Version

Possible Solution

Additional context/Screenshots

KeithClarke commented 3 years ago

I'm seeing this too - see https://salesforce.stackexchange.com/questions/350086/unable-to-run-a-lwc-jest-test-for-a-custom-lwc-that-uses-lightning-quick-action/350098.