Giter Site home page Giter Site logo

Comments (13)

jsdario avatar jsdario commented on April 28, 2024 4

Is there anyway to work this around? I had the issue above a long time running, I thought to maybe implement a function identical to idx locally rather using the babel plugin.

from idx.

yungsters avatar yungsters commented on April 28, 2024 1

Interesting! I wonder if a coverage plugin is injecting extra AST nodes into the arrow function.

Thanks for that insight. I'll need to brainstorm with @cpojer about how to best proceed.

from idx.

yungsters avatar yungsters commented on April 28, 2024

@davscro What version of babel-plugin-idx are you using? This should have been fixed by 2b4c33c.

from idx.

davscro avatar davscro commented on April 28, 2024

hi @yungsters ,

"name": "babel-plugin-idx",
 "version": "1.5.1",

"name": "idx", 
"version": "1.5.0"

When I run tests directly from Webstorm everything is OK
screen shot 2017-05-11 at 10 16 41
screen shot 2017-05-11 at 10 17 06

But from console with yarn test i got an error:
Here is the test step: "test": "rimraf results && rimraf coverage && jest --config jest.config.json --coverage --bail"
screen shot 2017-05-11 at 10 18 54

from idx.

yungsters avatar yungsters commented on April 28, 2024

@davscro Can you share the contents of your jest.config.json?

from idx.

davscro avatar davscro commented on April 28, 2024

Sure @yungsters
jest.config.json

	"setupTestFrameworkScriptFile": "<rootDir>/setup-jasmine-env.js",
	"coverageReporters": [
		"text-summary",
		"html",
		"cobertura"
	],
	"setupFiles": [
		"<rootDir>/test-setup.js"
	],
	"snapshotSerializers": [
		"<rootDir>/node_modules/enzyme-to-json/serializer"
	],
	"globals": {
		"__DEV__": true
	},
	"coverageThreshold": {
		"global": {
			"branches": 35,
			"functions": 50,
			"lines": 55,
			"statements": 50
		}
	}
}

setup-jasmine-env.js

/* eslint-disable no-undef */
const jasmineReporters = require('jasmine-reporters');

jasmine.VERBOSE = true;
jasmine.getEnv().addReporter(
	new jasmineReporters.JUnitXmlReporter({
		consolidateAll: false,
		savePath: './results',
		filePrefix: 'test-results'
	})
);

test-setup.js

window.matchMedia = window.matchMedia || function() {
	return {
		matches : false,
		addListener : function() {},
		removeListener: function() {}
	};
};

from idx.

michalkvasnicak avatar michalkvasnicak commented on April 28, 2024

I have the same problem. When I remove --coverage from command, everything works just fine.

from idx.

yungsters avatar yungsters commented on April 28, 2024

Hmm... this is an unfortunate collision between the two plugins. I don't have time to dig into this, but if we could identify the output of the coverage plugin, we can add a special case in babel-plugin-idx to ignore the extra nodes introduced by the coverage plugin.

Open to other ideas, too.

from idx.

JanPeter avatar JanPeter commented on April 28, 2024

Isn't idx just a "hopefully" temporary wrapper around the new optional chaining proposal? If there is currently a babel implementation of the optional chaining proposal, it would be interesting if jest coverage would work with them.

Correct me if I'm wrong, but at least to me it seems that the babel implementation shouldn't be that different?

from idx.

dolphin278 avatar dolphin278 commented on April 28, 2024
const f = () => 'a';

turns during jest run with coverage into

() => {/* istanbul ignore next */++cov_14mnsv87h8.f[0];++cov_14mnsv87h8.s[1];return 'a';}

So, when this transformation applied to idx's fake function argument, it violates idx's assertions (not a single stmt, curly braces, referencing values other than single argument's properties, etc).

from idx.

dolphin278 avatar dolphin278 commented on April 28, 2024

Looks like babel 7 could solve this issue - it puts each plugin on separate compilation pass, which may prevent conflict between idx babel plugin and instanbul plugin, that included by babel-jest in babel config when we run jest with --coverage.

from idx.

jsdario avatar jsdario commented on April 28, 2024

You can also use the following workaround jestjs/jest#3549 (comment)

TL;DR use the idx as a package, but don't take the compilation step for the test phase

from idx.

yungsters avatar yungsters commented on April 28, 2024

This issue is almost a year old now. I'm going to close it out, but please do file a new one if this is still a problem (with Babel 7).

from idx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.