Skip to content
Closed
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
18 changes: 18 additions & 0 deletions packages/js-sdk/tests/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,24 @@ export const buildTemplateTest = base.extend<BuildTemplateFixture>({
],
})

/**
* Creates a build template test that is allowed to fail without breaking CI.
* - If the test passes → test passes (ideal outcome)
* - If the test fails → logs ALLOW_FAIL and test still passes
*/
export function buildTemplateTestAllowFail(
name: string,
fn: (fixtures: BuildTemplateFixture) => Promise<void>
) {
return buildTemplateTest(name, async ({ buildTemplate }) => {
try {
await fn({ buildTemplate })
} catch (error) {
console.error(`\n[ALLOW_FAIL] ${name}: ${error}`)
}
})
}

export const isDebug = process.env.E2B_DEBUG !== undefined
export const isIntegrationTest = process.env.E2B_INTEGRATION_TEST !== undefined

Expand Down
6 changes: 3 additions & 3 deletions packages/js-sdk/tests/template/methods/aptInstall.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Template } from '../../../src'
import { buildTemplateTest } from '../../setup'
import { buildTemplateTestAllowFail } from '../../setup'

buildTemplateTest('apt install', async ({ buildTemplate }) => {
buildTemplateTestAllowFail('apt install', async ({ buildTemplate }) => {
const template = Template()
.fromImage('ubuntu:24.04')
.skipCache()
Expand All @@ -10,7 +10,7 @@ buildTemplateTest('apt install', async ({ buildTemplate }) => {
await buildTemplate(template)
})

buildTemplateTest(
buildTemplateTestAllowFail(
'apt install with no install recommends',
async ({ buildTemplate }) => {
const template = Template()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@


@pytest.mark.skip_debug()
@pytest.mark.xfail(reason="aptInstall tests are optional and allowed to fail")
async def test_apt_install(async_build):
template = (
AsyncTemplate().from_image("ubuntu:24.04").skip_cache().apt_install("rolldice")
Expand All @@ -13,6 +14,7 @@ async def test_apt_install(async_build):


@pytest.mark.skip_debug()
@pytest.mark.xfail(reason="aptInstall tests are optional and allowed to fail")
async def test_apt_install_no_install_recommends(async_build):
template = (
AsyncTemplate()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@


@pytest.mark.skip_debug()
@pytest.mark.xfail(reason="aptInstall tests are optional and allowed to fail")
def test_apt_install(build):
template = (
Template().from_image("ubuntu:24.04").skip_cache().apt_install("rolldice")
Expand All @@ -13,6 +14,7 @@ def test_apt_install(build):


@pytest.mark.skip_debug()
@pytest.mark.xfail(reason="aptInstall tests are optional and allowed to fail")
def test_apt_install_no_install_recommends(build):
template = (
Template()
Expand Down