-
Notifications
You must be signed in to change notification settings - Fork 18
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
Coverage lines incorrect #28
Comments
I'm using I tried adding |
I investigated this issue raised in our repository (wallabyjs/public#2669) and the issue is lies within Svelte-jester allows source maps to be generated and used by consumers but does not call the svelte pre-processor (https://github.com/mihar-22/svelte-jester/blob/2337944e0044e460a086aaf6c48e1b2c98d341e7/src/preprocess.js#L8) with To fix this problem, the source maps need to be obtained from the Here is a test that reproduces the issue: const transformer = require("../transformer");
const sourceMap = require("source-map");
describe("typescript line mappings tests", () => {
it("should correctly map preprocessed files back to original lines", async () => {
const source =
`<div>Hello {name}</div>
<script lang="typescript">
export let name: string = ''
console.log('Test this line');
</script>
`
const options = { preprocess: true };
const process = transformer.createTransformer(options).process;
const result = process(source, 'dummyFile.svelte');
expect(result.code).toBeDefined();
expect(result.code).toContain("SvelteComponent");
expect(result.map).toBeDefined();
const originalLines = source.replace(/\r/g, '').split('\n');
const transformedLines = result.code.replace(/\r/g, '').split('\n');
const consoleLogLineOriginal = originalLines.findIndex(item => item.indexOf('Test this line') !== -1);
const consoleLogLineTransformed = transformedLines.findIndex(item => item.indexOf('Test this line') !== -1);
expect(consoleLogLineOriginal).not.toBe(undefined);
expect(consoleLogLineTransformed).not.toBe(undefined);
const sourceMapConsumer = await new sourceMap.SourceMapConsumer(result.map);
let generatedLine = undefined;
sourceMapConsumer.eachMapping((mapping) => {
if (mapping.originalLine === consoleLogLineOriginal) {
if (!generatedLine) {
generatedLine = mapping.generatedLine;
} else if (generatedLine !== mapping.generatedLine) {
throw new Error('Incorrectly maps to multiple lines');
}
}
});
expect(generatedLine).toBe(consoleLogLineTransformed);
});
}); |
Done and released in Apologies on the delay I was just busy with work. |
Thanks for the detailed information and feedback @smcenlly, much appreciated... helped me debug issue faster. |
Hate to be a party pooper but started using 1.3.1 and I'm now seeing Here's the svelte file <!-- NoResource.svelte -->
<script lang="ts">
import Tumbleweed from './Tumbleweed.svelte';
</script>
<div class="h-full w-full flex flex-col justify-center items-center">
<p class="snapshot-text text-4xl text-center font-semibold opacity-40 mb-6">
Resource Does Not Exist
</p>
<div class="h-2/6 w-full opacity-40">
<Tumbleweed />
</div>
</div>
<style>
.snapshot-text {
font-family: 'Balsamiq Sans', cursive;
}
</style> Error stack trace
This is the value that valueToNode receives as argument: Will try to look more into exactly why this file fails and none of the other ones do when I get the time, any help troubleshooting is appreciated! |
Ah yucky damn. Open a new issue up please and let's see if it's only related to Babel. |
Opened #33 for this |
I'm using
svelte-jester
withpreprocess
->babel
. When I use collect coverage, the line numbers appear to be wrong. Is this something that is fixable within this library?The text was updated successfully, but these errors were encountered: