Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ integration-tests/test-files/output.wasm
# compiler_flags

/runtime/fastedge/build-*
/runtime/fastedge/deps/
*.a
yarn-error.log

Expand Down
8 changes: 7 additions & 1 deletion config/jest/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ const config = {
moduleFileExtensions: ['ts', 'js', 'json'],
rootDir: process.cwd(),
testEnvironment: 'node',
testPathIgnorePatterns: ['node_modules', 'dist', 'docs', 'runtime/StarlingMonkey/'],
testPathIgnorePatterns: [
'node_modules',
'dist',
'docs',
'runtime/StarlingMonkey/',
'runtime/fastedge/deps',
],
transform: {
'^.+\\.(ts|js)$': 'babel-jest',
},
Expand Down
28 changes: 26 additions & 2 deletions integration-tests/fastedge-build.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ describe('fastedge-build', () => {
expect(distFolderExists).toBe(true);
await cleanup();
});
it.each(['js', 'jsx', 'cjs', 'mjs', 'ts', 'tsx'])(
'should handle all valid file extensions ".%s"',
it.each(['js', 'cjs', 'mjs'])(
'should handle all valid javascript file extensions ".%s"',
async (ext) => {
expect.assertions(3);
const { execute, cleanup, writeFile } = await prepareEnvironment();
Expand All @@ -88,6 +88,30 @@ describe('fastedge-build', () => {
await cleanup();
},
);

it.each(['jsx', 'ts', 'tsx'])(
// .jsx is supported using tsc compiler
'should handle all valid typescript file extensions ".%s"',
async (ext) => {
expect.assertions(3);
const { execute, cleanup, path, writeFile } = await prepareEnvironment();
const filename = `input.${ext}`;
spawnSync('npm', ['install', 'typescript'], {
stdio: 'inherit',
cwd: path,
});
await writeFile(filename, 'function hello() { console.log("Hello World"); }');
await writeFile('./lib/fastedge-runtime.wasm', 'Some binary data');
const { code, stdout, stderr } = await execute(
'node',
`./bin/fastedge-build.js ${filename} dist/output.wasm`,
);
expect(code).toBe(0);
expect(stderr).toHaveLength(0);
expect(stdout[0]).toContain('Build success!!');
await cleanup();
},
);
it.each(['txt', 'wasm', 'pdf', 'xml', 'jpg'])(
'should exit with an error if the input is not a Javascript file ".%s"',
async (ext) => {
Expand Down
Loading