Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Add tests for stdout/err
Jakub Novakafbececfd0dd
diff --git a/packages/js-sdk/test/runCode.test.mjs b/packages/js-sdk/test/runCode.test.mjsindex 2333c4447..fb606f0c9 100644--- a/packages/js-sdk/test/runCode.test.mjs+++ b/packages/js-sdk/test/runCode.test.mjs@@ -1,18 +1,19 @@-import { runCode } from '../src'-import { expect, test } from 'vitest'+import {runCode} from '../src'+import {expect, test} from 'vitest'-// test('run code', async () => {-// const code = `-// print("hello")-// raise Exception("err")-// `-// const { stdout, stderr } = await runCode('Python3', code)-// console.log('stdout', stdout)-// console.log('stderr', stderr)+test('run code', async () => {-// expect(stdout).toEqual('hello')-// // expect(stderr).toContain('Exception: err')-// })+ const code = `+test="test\\n"+print(10*test)+raise Exception("err")+`+ const {stdout, stderr} = await runCode('PPSrlH5TIvFx', code)+ console.log('stdout', stdout)+ console.log('stderr', stderr)+ expect(stdout.length).toEqual(50)+ expect(stderr).toContain('Exception: err')+})test('run code using unsupported runtime', async () => {await expect(() => runCode('Unsupported', 'print("hello")')).rejects.toThrowError(diff --git a/packages/python-sdk/tests/test_run_code.py b/packages/python-sdk/tests/test_run_code.pyindex cd2f4574d..5407cfd70 100644--- a/packages/python-sdk/tests/test_run_code.py+++ b/packages/python-sdk/tests/test_run_code.py@@ -5,10 +5,10 @@ from e2b.session.exception import UnsupportedRuntimeExceptionasync def test_run_code():- code = "console.log('hello'); throw new Error('error')"+ code = "console.log('hello\\n'.repeat(10)); throw new Error('error')"stdout, stderr = await run_code("Node16", code)- assert stdout == "hello"+ assert len(stdout) == 60assert "Error: error" in stderrdiff --git a/packages/python-sdk/tests/test_session.py b/packages/python-sdk/tests/test_session.pyindex e227bb927..29f06786a 100644--- a/packages/python-sdk/tests/test_session.py+++ b/packages/python-sdk/tests/test_session.py@@ -22,7 +22,7 @@ async def test_custom_cwd():# filesystem ops does not respect the cwd yetawait session.filesystem.write("hello.txt", "Hello VM!")- proc = await session.process.start("cat /hello.txt") # notice the file is in root+ proc = await session.process.start("cat /hello.txt") # notice the file is in rootoutput = await procassert output.stdout == "Hello VM!"