diff --git a/tests/Feature/IntegrationTest.php b/tests/Feature/IntegrationTest.php index 5d637cb..2df4ca5 100644 --- a/tests/Feature/IntegrationTest.php +++ b/tests/Feature/IntegrationTest.php @@ -57,6 +57,32 @@ JS ); +// These two should be browser tests? or can we get the file's hash some other wayy? +test('generated bundles are reachable over http')->todo(); +test('generated chunks are reachable over http')->skip('Code splitting not implemented'); + + +it('generates sourcemaps when enabled') + ->defer( + fn () => config()->set('bundle.sourcemaps_enabled', true) + ) + ->bundle( + <<< JS + const filter = await import('lodash/filter') + JS + ) + ->content() + ->toContain('//# debugId'); + +it('doesnt generate sourcemaps by default') + ->bundle( + <<< JS + const filter = await import('lodash/filter') + JS + ) + ->content() + ->not->toContain('//# debugId'); + it('imports from node_modules are chunked')->todo(); it('imports from outside node_modules are inlined (due to issue with Bun)')->todo(); diff --git a/tests/Pest.php b/tests/Pest.php index 6981d05..68b1069 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -41,8 +41,11 @@ expect()->extend('transpilesTo', function (string $expected = '') { // Add newline to passed expectation, this isn't present when passing HEREDOC $expected = $expected . PHP_EOL; + return expect($this->value)->content()->toBe($expected); +}); - return expect($this->value)->toBe($expected); +expect()->extend('content', function (string $expected = '') { + return expect($this->value); }); /*