Skip to content

Commit a1771db

Browse files
test(cli): add tests for Netlify, Cloudflare, and Vercel providers
1 parent 13103d9 commit a1771db

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

packages/cli/tests/create-tutorial.test.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,49 @@ test('create a project', async (context) => {
4949
expect(projectFiles.map(normaliseSlash).sort()).toMatchSnapshot();
5050
});
5151

52+
test('create a project with Netlify as provider', async (context) => {
53+
const name = context.task.id;
54+
const dest = path.join(tmpDir, name);
55+
56+
await execa('node', [cli, 'create', name, '--no-install', '--no-git', '--defaults', '--provider', 'netlify'], {
57+
cwd: tmpDir,
58+
});
59+
60+
const projectFiles = await fs.readdir(dest, { recursive: true });
61+
expect(projectFiles).toContain('netlify.toml');
62+
});
63+
64+
test('create a project with Cloudflare as provider', async (context) => {
65+
const name = context.task.id;
66+
const dest = path.join(tmpDir, name);
67+
68+
await execa('node', [cli, 'create', name, '--no-install', '--no-git', '--defaults', '--provider', 'cloudflare'], {
69+
cwd: tmpDir,
70+
});
71+
72+
const projectFiles = await fs.readdir(dest, { recursive: true });
73+
expect(projectFiles).toContain('wrangler.toml');
74+
75+
const packageJson = await fs.readFile(`${dest}/package.json`, 'utf8');
76+
const json = JSON.parse(packageJson);
77+
78+
expect(json).toHaveProperty('scripts');
79+
expect(json.scripts).toHaveProperty('postbuild');
80+
expect(json.scripts.postbuild).toBe('cp _headers ./dist/');
81+
});
82+
83+
test('create a project with Vercel as provider', async (context) => {
84+
const name = context.task.id;
85+
const dest = path.join(tmpDir, name);
86+
87+
await execa('node', [cli, 'create', name, '--no-install', '--no-git', '--defaults', '--provider', 'vercel'], {
88+
cwd: tmpDir,
89+
});
90+
91+
const projectFiles = await fs.readdir(dest, { recursive: true });
92+
expect(projectFiles).toContain('vercel.json');
93+
});
94+
5295
test('create and build a project', async (context) => {
5396
const name = context.task.id;
5497
const dest = path.join(tmpDir, name);

0 commit comments

Comments
 (0)