Skip to content

Instantly share code, notes, and snippets.

@fvsch
Created March 30, 2023 09:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fvsch/81c7301f8f2fa3d2ec8fc39f1e7354f9 to your computer and use it in GitHub Desktop.
Save fvsch/81c7301f8f2fa3d2ec8fc39f1e7354f9 to your computer and use it in GitHub Desktop.
Testing the StackBlitz SDK from a browser's console
void (async function () {
// set origin to the StackBlitz instance you want to test
const origin = 'https://stackblitz.com';
const sdk = await import(
'https://unpkg.com/@stackblitz/sdk@1/bundles/sdk.m.js'
).then((module) => module.default);
const jsProject = {
title: 'JS Project',
template: 'javascript',
files: { 'index.js': '// JavaScript', 'index.html': '' },
};
const nodeProject = {
title: 'Node Project',
template: 'node',
files: { 'index.js': '// Node' },
};
const unknownTemplateProject = {
title: 'Unknown Template',
template: 'lolwhat',
files: { 'index.js': '// JavaScript', 'index.html': '' },
};
[jsProject, nodeProject, unknownTemplateProject].forEach((project, index) => {
setTimeout(
() => sdk.openProject(project, { newWindow: true, origin }),
index * 1_000
);
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment