Repository: withastro/astro
File: packages/astro/test/server-islands.test.js (JavaScript)

Code before:
		});

		describe('dev', () => {
			let devServer;

			before(async () => {
				process.env.ASTRO_KEY = 'eKBaVEuI7YjfanEXHuJe/pwZKKt3LkAHeMxvTU7aR0M=';
				devServer = await fixture.startDevServer();
			});

			after(async () => {
				await devServer.stop();
				delete process.env.ASTRO_KEY;
			});

			it('omits the islands HTML', async () => {
				const res = await fixture.fetch('/');
				assert.equal(res.status, 200);
				const html = await res.text();
				const $ = cheerio.load(html);
				const serverIslandEl = $('h2#island');
				assert.equal(serverIslandEl.length, 0);
			});

			it('island is not indexed', async () => {
				const res = await fixture.fetch('/_server-islands/Island');
				assert.equal(res.headers.get('X-Robots-Tag'), 'noindex');
			});

			it('island can set headers', async () => {
				const res = await fixture.fetch('/_server-islands/Island', {
					method: 'POST',
					body: JSON.stringify({
						componentExport: 'default',
						encryptedProps: 'FC8337AF072BE5B1641501E1r8mLIhmIME1AV7UO9XmW9OLD',
						slots: {},
					}),
				});
				const works = res.headers.get('X-Works');
				assert.equal(works, 'true', 'able to set header from server island');
			});
		});

		describe('prod', () => {
			before(async () => {
				process.env.ASTRO_KEY = 'eKBaVEuI7YjfanEXHuJe/pwZKKt3LkAHeMxvTU7aR0M=';
				await fixture.build();
			});

			after(async () => {
				delete process.env.ASTRO_KEY;

Review comment (bug):
this is failing because you're not providing a body. Change it to a POST and do like in the other test, here: https://github.com/withastro/astro/blob/2d02170611a1d75e7dad00e1b86ffbb962c0b699/packages/astro/test/server-islands.test.js#L48-L52

Code after:
		});

		describe('dev', () => {
			let devServer;

			before(async () => {
				process.env.ASTRO_KEY = 'eKBaVEuI7YjfanEXHuJe/pwZKKt3LkAHeMxvTU7aR0M=';
				devServer = await fixture.startDevServer();
			});

			after(async () => {
				await devServer.stop();
				delete process.env.ASTRO_KEY;
			});

			it('omits the islands HTML', async () => {
				const res = await fixture.fetch('/');
				assert.equal(res.status, 200);
				const html = await res.text();
				const $ = cheerio.load(html);
				const serverIslandEl = $('h2#island');
				assert.equal(serverIslandEl.length, 0);
			});

			it('island is not indexed', async () => {
				const res = await fixture.fetch('/_server-islands/Island', {
					method: 'POST',
					body: JSON.stringify({
						componentExport: 'default',
						encryptedProps: 'FC8337AF072BE5B1641501E1r8mLIhmIME1AV7UO9XmW9OLD',
						slots: {},
					}),
				});
				assert.equal(res.headers.get('x-robots-tag'), 'noindex');
			});

			it('island can set headers', async () => {
				const res = await fixture.fetch('/_server-islands/Island', {
					method: 'POST',
					body: JSON.stringify({
						componentExport: 'default',
						encryptedProps: 'FC8337AF072BE5B1641501E1r8mLIhmIME1AV7UO9XmW9OLD',
						slots: {},
					}),
				});
				const works = res.headers.get('X-Works');
				assert.equal(works, 'true', 'able to set header from server island');
			});
		});

		describe('prod', () => {