svelte-declarative-testing 0.3.2 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
2
|
|
|
3
|
-
exports[`vitest post plugin > produces code that mounts the component and returns a render result 1`] = `"export default function AComponent() {};import { mount } from "svelte";
|
|
3
|
+
exports[`vitest post plugin > produces code that mounts the component and returns a render result 1`] = `"export default function AComponent() {};import { mount as svelte_declarative_testing_mount } from "svelte";svelte_declarative_testing_mount(AComponent_test, { target: document.body });"`;
|
|
4
4
|
|
|
5
5
|
exports[`vitest pre plugin > produces code with a dummy test suite 1`] = `
|
|
6
6
|
"
|
package/src/plugins/vitest.js
CHANGED
|
@@ -17,8 +17,8 @@ import { SourceMapGenerator, SourceMapConsumer } from 'source-map';
|
|
|
17
17
|
* imported so that the tests run.
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
const
|
|
21
|
-
|
|
20
|
+
const getMountCode = (/**@type {string}*/ name) =>
|
|
21
|
+
`;import { mount as svelte_declarative_testing_mount } from "svelte";svelte_declarative_testing_mount(${name}, { target: document.body });`;
|
|
22
22
|
|
|
23
23
|
const testFileRegex = /\.(?:test|spec)\.svelte$/;
|
|
24
24
|
const getNameFromAttr = (node, attr) =>
|
|
@@ -123,9 +123,10 @@ const post = () => ({
|
|
|
123
123
|
|
|
124
124
|
const s = new MagicString(code);
|
|
125
125
|
|
|
126
|
-
//
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
// TODO: find a more robust way to get the component name
|
|
127
|
+
const name = id.split('/').pop().replace('.svelte', '').replace(/\./g, '_');
|
|
128
|
+
|
|
129
|
+
s.append(getMountCode(name));
|
|
129
130
|
|
|
130
131
|
return { code: s.toString() };
|
|
131
132
|
},
|