1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00

test(jsr): add tests for jsx files with and without pragmas (#22634)

Follow up to https://github.com/denoland/deno/pull/22631 that asserts
behavior when JSX and TSX files have and do not have pragmas with 
`jsx*` config.
This commit is contained in:
Bartek Iwańczuk 2024-02-29 18:35:23 +00:00 committed by GitHub
parent 8d9a54ca18
commit a9aef0d017
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 173 additions and 0 deletions

View file

@ -8,6 +8,7 @@ use test_util::itest;
use url::Url;
use util::assert_contains;
use util::assert_not_contains;
use util::env_vars_for_jsr_npm_tests;
use util::env_vars_for_jsr_tests;
use util::TestContextBuilder;
@ -477,3 +478,19 @@ fn set_lockfile_pkg_integrity(
.unwrap()
.integrity = integrity.to_string();
}
itest!(jsx_with_no_pragmas {
args: "run jsr/jsx_with_no_pragmas/main.ts",
output: "jsr/jsx_with_no_pragmas/main.out",
envs: env_vars_for_jsr_npm_tests(),
http_server: true,
exit_code: 1,
});
itest!(jsx_with_pragmas {
args: "run jsr/jsx_with_pragmas/main.ts",
output: "jsr/jsx_with_pragmas/main.out",
envs: env_vars_for_jsr_npm_tests(),
http_server: true,
exit_code: 0,
});

View file

@ -0,0 +1,7 @@
Download [WILDCARD]
error: Uncaught (in promise) ReferenceError: React is not defined
return renderToString(<div>foo.jsx</div>);
^
at render (http://127.0.0.1:4250/@denotest/jsx-with-no-pragmas/1.0.0/foo.jsx:4:25)
at render (http://127.0.0.1:4250/@denotest/jsx-with-no-pragmas/1.0.0/mod.ts:5:15)
at file:///[WILDCARD]/jsr/jsx_with_no_pragmas/main.ts:3:1

View file

@ -0,0 +1,3 @@
import { render } from "jsr:@denotest/jsx-with-no-pragmas@1.0.0";
render();

View file

@ -0,0 +1,3 @@
Download [WILDCARD]
<div>foo.jsx</div>
<div>foo.tsx</div>

View file

@ -0,0 +1,3 @@
import { render } from "jsr:@denotest/jsx-with-pragmas@1.0.0";
render();

View file

@ -0,0 +1,5 @@
import { renderToString } from "npm:preact-render-to-string";
export default function render() {
return renderToString(<div>foo.jsx</div>);
}

View file

@ -0,0 +1,5 @@
import { renderToString } from "npm:preact-render-to-string";
export default function render() {
return renderToString(<div>foo.tsx</div>);
}

View file

@ -0,0 +1,7 @@
import renderJsx from "./foo.jsx";
import renderTsx from "./foo.tsx";
export function render() {
console.log(renderJsx());
console.log(renderTsx());
}

View file

@ -0,0 +1,40 @@
{
"exports": {
".": "./mod.ts"
},
"moduleGraph1": {
"/mod.ts": {
"dependencies": [{
"type": "static",
"kind": "import",
"range": [[0, 0], [0, 35]],
"specifier": "./foo.jsx",
"specifierRange": [[0, 22], [0, 33]]
}, {
"type": "static",
"kind": "import",
"range": [[1, 0], [1, 25]],
"specifier": "./foo.tsx",
"specifierRange": [[1, 22], [1, 33]]
}]
},
"/foo.jsx": {
"dependencies": [{
"type": "static",
"kind": "import",
"range": [[0, 0], [0, 60]],
"specifier": "npm:preact-render-to-string",
"specifierRange": [[0, 32], [0, 60]]
}]
},
"/foo.tsx": {
"dependencies": [{
"type": "static",
"kind": "import",
"range": [[0, 0], [0, 60]],
"specifier": "npm:preact-render-to-string",
"specifierRange": [[0, 32], [0, 60]]
}]
}
}
}

View file

@ -0,0 +1,5 @@
{
"versions": {
"1.0.0": {}
}
}

View file

@ -0,0 +1,7 @@
/** @jsxRuntime automatic *//** @jsxImportSource npm:preact */
// deno-fmt-ignore-file
import { renderToString } from "npm:preact-render-to-string";
export default function render() {
return renderToString(<div>foo.jsx</div>);
}

View file

@ -0,0 +1,7 @@
/** @jsxRuntime automatic *//** @jsxImportSource npm:preact */
// deno-fmt-ignore-file
import { renderToString } from "npm:preact-render-to-string";
export default function render() {
return renderToString(<div>foo.tsx</div>);
}

View file

@ -0,0 +1,7 @@
import renderJsx from "./foo.jsx";
import renderTsx from "./foo.tsx";
export function render() {
console.log(renderJsx());
console.log(renderTsx());
}

View file

@ -0,0 +1,52 @@
{
"exports": {
".": "./mod.ts"
},
"moduleGraph1": {
"/mod.ts": {
"dependencies": [{
"type": "static",
"kind": "import",
"range": [[0, 0], [0, 35]],
"specifier": "./foo.jsx",
"specifierRange": [[0, 22], [0, 33]]
}, {
"type": "static",
"kind": "import",
"range": [[1, 0], [1, 25]],
"specifier": "./foo.tsx",
"specifierRange": [[1, 22], [1, 33]]
}]
},
"/foo.jsx": {
"dependencies": [{
"type": "static",
"kind": "import",
"range": [[0, 0], [0, 60]],
"specifier": "npm:preact/jsx-runtime",
"specifierRange": [[0, 32], [0, 60]]
}, {
"type": "static",
"kind": "import",
"range": [[2, 0], [2, 60]],
"specifier": "npm:preact-render-to-string",
"specifierRange": [[2, 32], [2, 60]]
}]
},
"/foo.tsx": {
"dependencies": [{
"type": "static",
"kind": "import",
"range": [[0, 0], [0, 60]],
"specifier": "npm:preact/jsx-runtime",
"specifierRange": [[0, 32], [0, 60]]
}, {
"type": "static",
"kind": "import",
"range": [[2, 0], [2, 60]],
"specifier": "npm:preact-render-to-string",
"specifierRange": [[2, 32], [2, 60]]
}]
}
}
}

View file

@ -0,0 +1,5 @@
{
"versions": {
"1.0.0": {}
}
}