Skip to content

Commit

Permalink
add tests for sourcemaps feature
Browse files Browse the repository at this point in the history
  • Loading branch information
gwleuverink committed Jan 11, 2024
1 parent 601b7b3 commit 61e11b1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
26 changes: 26 additions & 0 deletions tests/Feature/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 4 additions & 1 deletion tests/Pest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

/*
Expand Down

0 comments on commit 61e11b1

Please sign in to comment.